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

Fix breakage caused by change in django-timezone-field #378

Merged
merged 2 commits into from
Dec 4, 2020
Merged

Fix breakage caused by change in django-timezone-field #378

merged 2 commits into from
Dec 4, 2020

Conversation

davidrothera
Copy link
Contributor

In mfogel/django-timezone-field@0c6a6ba the CHOICES property was removed, it was replaced with two new fields default_tzs and default_choices. The latter of the two is the same choices as before and so we just use that now instead.

Fixes #377

@arnau126
Copy link
Contributor

With this change, django-celery-beat will no longer work with django-timezone-field==4.0.

I see two options:

  1. Modify the minimum required version of django-timezone-field in requirements: django-timezone-field>=4.1,<5.0
  2. Make the code work with both versions: modify django_celery_beat/models.py so it uses CHOICES or default_choices depending on the django-timezone-field version.

@davidrothera
Copy link
Contributor Author

Great point @arnau126, I had meant to pin the requirements but forgot in the initial PR

@davidrothera
Copy link
Contributor Author

Another option would be to parse and gate by using the timezone_field.__version__ field with something like the packaging.version.parse method but it would require another third-party dependency (one already used by setup tools though so its more than likely already installed)

@@ -57,7 +57,8 @@ def crontab_schedule_celery_timezone():
except AttributeError:
return 'UTC'
return CELERY_TIMEZONE if CELERY_TIMEZONE in [
choice[0].zone for choice in timezone_field.TimeZoneField.CHOICES
choice[0].zone for choice in timezone_field.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this also need change in model migrations?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@auvipy I don't think any other changes will be needed, the tuples outputted by TimeZoneField.CHOICES and default_choices are the same and so the data should be the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(venv) ~/D/django-celery-beat ❯❯❯ python3.9 manage.py makemigrations                                                                         master
No changes detected

@auvipy auvipy merged commit 6d8347f into celery:master Dec 4, 2020
@tasiotas
Copy link

tasiotas commented Dec 23, 2020

hi, Im not quite knowlegable with github, PR and merging.
I am using:
django-celery-beat 2.1.0
django-timezone-field 4.1.1

and getting this error:

django_celery_beat\models.py", line 60, in crontab_schedule_celery_timezone
    choice[0].zone for choice in timezone_field.TimeZoneField.CHOICES
AttributeError: type object 'TimeZoneField' has no attribute 'CHOICES'

Is there anything im missing?

@arnau126
Copy link
Contributor

This PR has fixed your error.
It is merged, but not released.
Until then (django-celery-beat 2.1.1 is released) downgrade django-timezone-field to 4.0.

@tasiotas
Copy link

This PR has fixed your error.
It is merged, but not released.
Until then (django-celery-beat 2.1.1 is released) downgrade django-timezone-field to 4.0.

Thank you!

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

Successfully merging this pull request may close these issues.

Latest Version of django-timezone-field breaks django-celery-beat
5 participants