django-celery icon indicating copy to clipboard operation
django-celery copied to clipboard

Changing instances of ugettext, ugettext_lazy, ungettext, and force_unicode for Django 4.0

Open TomBlackwoodTTM opened this issue 3 years ago • 2 comments

Hi,

I don't know if people running Django 4.0 will be using django-celery but I had to make some fixes to djcelery in order to get it working.

I had to delete the u from:

  • ugettext to just gettext
  • ugettext_lazy to just gettext_lazy
  • ungettext to use ngettext and then import it as ungettext to leave the rest of the code "reasonably unchanged".

Lastly I changed the force_unicode (force_text) import to import force_str as force_text

The files affected I think were:

  • djcelery/admin.py
  • djcelery/humanize.py
  • djcelery/models.py
  • djcelery/picklefield.py

It imports correctly now but I can keep you posted on if it breaks!

TomBlackwoodTTM avatar May 26 '22 11:05 TomBlackwoodTTM

Hi,

I have changed files that you mention and did what you say, and now it throw an error like this :

File "/home/fariz/.virtualenvs/boxsurat/lib/python3.8/site-packages/djcelery/models.py", line 17, in from .picklefield import PickledObjectField File "/home/fariz/.virtualenvs/boxsurat/lib/python3.8/site-packages/djcelery/picklefield.py", line 22, in from celery.five import with_metaclass ModuleNotFoundError: No module named 'celery.five'

muhammadfarizarya avatar Sep 30 '22 19:09 muhammadfarizarya

Hi,

I've been looking for a solution and doing this to got it working for a while but I don't know what effect I did

The files :

  • djcelery/admin.py
  • djcelery/picklefield.py

what I did:

  • remove from celery.five import with_metaclass
  • change from celery.app.control import broadcast, revoke, rate_limit to from celery.worker.control import revoke, rate_limit
  • change 'broadcast()' to self.app.control.broadcast()

I hope it can work well

muhammadfarizarya avatar Sep 30 '22 20:09 muhammadfarizarya