hugsy / ctfhub

Where CTFs happen
77 stars 13 forks source link

[docker-compose] Error with Django 4: `cannot import name 'ugettext_lazy'` #54

Closed m4ul3r closed 2 years ago

m4ul3r commented 2 years ago

It appears that ugettext_lazy has been removed in django 4+ and is now just gettext_laxy. The import needs to be changed at ctfpad/apps.py

ctfpad_1      | Traceback (most recent call last):                                                                                                                                            
ctfpad_1      |   File "/code/manage.py", line 22, in <module>                                                                                                                                
ctfpad_1      |     main()                                                                                                                                                                    
ctfpad_1      |   File "/code/manage.py", line 18, in main                                                                                                                                    
ctfpad_1      |     execute_from_command_line(sys.argv)                                        
ctfpad_1      |   File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
ctfpad_1      |     utility.execute()                                                                                                                                                         
ctfpad_1      |   File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 420, in execute
ctfpad_1      |     django.setup()                                                                                                                                                            
ctfpad_1      |   File "/usr/local/lib/python3.9/site-packages/django/__init__.py", line 24, in setup
ctfpad_1      |     apps.populate(settings.INSTALLED_APPS)                                                                                                                                    ctfpad_1      |   File "/usr/local/lib/python3.9/site-packages/django/apps/registry.py", line 91, in populate                                                                                 
ctfpad_1      |     app_config = AppConfig.create(entry)                                                                                                                                      ctfpad_1      |   File "/usr/local/lib/python3.9/site-packages/django/apps/config.py", line 126, in create                                                                                    
ctfpad_1      |     mod = import_module(mod_path)                                                                                                                                             
ctfpad_1      |   File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
ctfpad_1      |     return _bootstrap._gcd_import(name[level:], package, level)                                                                                                               
ctfpad_1      |   File "<frozen importlib._bootstrap>", line 1030, in _gcd_import              
ctfpad_1      |   File "<frozen importlib._bootstrap>", line 1007, in _find_and_load                                                                                                          
ctfpad_1      |   File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked                                                                                                  
ctfpad_1      |   File "<frozen importlib._bootstrap>", line 680, in _load_unlocked                                                                                                           ctfpad_1      |   File "<frozen importlib._bootstrap_external>", line 850, in exec_module                                                                                                     
ctfpad_1      |   File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed                                                                                                ctfpad_1      |   File "/code/ctfpad/apps.py", line 2, in <module>                                                                                                                            
ctfpad_1      |     from django.utils.translation import ugettext_lazy as _                                                                                                                   
ctfpad_1      | ImportError: cannot import name 'ugettext_lazy' from 'django.utils.translation' (/usr/local/lib/python3.9/site-packages/django/utils/translation/__init__.py)

https://forum.djangoproject.com/t/importerror-cannot-import-name-ugettext-lazy-from-django-utils-translation/10943/2

hugsy commented 2 years ago

Ok I wasn't aware of that, I'll check it out.

In the mean time you can always force the django version in the requirements file to make it work.

Cheers

hugsy commented 2 years ago

Fixed, works with Django 4+ only, moved postgres + hedgedoc to more recent versions