Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server error when USE_TZ = False #316

Open
sureshvv opened this issue Jul 30, 2023 · 7 comments
Open

Server error when USE_TZ = False #316

sureshvv opened this issue Jul 30, 2023 · 7 comments

Comments

@sureshvv
Copy link

  File "django42/lib/python3.8/site-packages/spirit/user/views.py", line 32, in update
    form = UserProfileForm(
  File "django42/lib/python3.8/site-packages/spirit/user/forms.py", line 103, in __init__
    now = timezone.localtime(timezone.now())
  File "django42/lib/python3.8/site-packages/django/utils/timezone.py", line 218, in localtime
    raise ValueError("localtime() cannot be applied to a naive datetime")

Exception Type: ValueError at /spirit/user/
Exception Value: localtime() cannot be applied to a naive datetime
Raised during: spirit.user.views.update

Changing forms.py line 103 to

now = timezone.now()

seems to have "fixed" it.

@nitely
Copy link
Owner

nitely commented Jul 30, 2023

CI runs on Django 4.2 and Python 3.8. Maybe it's a config issue, the default is USE_TZ = True and tz disabled is not supported.

@nitely
Copy link
Owner

nitely commented Jul 30, 2023

https://github.com/django/django/blob/main/django/utils/timezone.py#L204

It looks like your config has USE_TZ set to false

@sureshvv
Copy link
Author

I see I have USE_TZ commented out in my settings. It may be impacting another app that I am using.

@sureshvv
Copy link
Author

sureshvv commented Jul 31, 2023

Is there a way in django where you can extend settings.py from each installed app? It seems some of my problems are to do with the fact that I am installing Spirit on an existing site - so I have to retrofit all the changes onto my original settings.py. A mechanism to add to the settings.py from each installed app (with warnings for incompatibility) will improve the overall experience.

Is djconfig an attempt at doing this?

@nitely
Copy link
Owner

nitely commented Jul 31, 2023 via email

@nitely nitely changed the title Server error in version 0.13.0 Server error when USE_TZ = False Aug 3, 2023
@nitely
Copy link
Owner

nitely commented Aug 3, 2023

Leaving this open as Spirit should either work with USE_TZ = False or add a validator to core app to check it's True.

@nitely
Copy link
Owner

nitely commented Aug 3, 2023

Also created an issue to improve the settings validations #318

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants