jazzband / django-constance

Dynamic Django settings.
https://django-constance.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.66k stars 307 forks source link

collectstatic is broken by latest version #513

Closed dtcooper closed 1 year ago

dtcooper commented 1 year ago

Describe the problem

Running ./manage.py collectstatic throws an ImproperlyConfigured exception on the latest version (79fd8af0f4456b8ef717fbe10a6db835fe923d8d).

Steps to reproduce

./manage.py runserver works just fine, but when I run ./manage.py collectstatic, I get the following exception,

root@c13249cd9810:/app# ./manage.py collectstatic
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/constance/models.py", line 7, in <module>
    from picklefield import PickledObjectField
ModuleNotFoundError: No module named 'picklefield'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/./manage.py", line 24, in <module>
    main()
  File "/app/./manage.py", line 20, in main
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.11/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.11/site-packages/django/core/management/__init__.py", line 420, in execute
    django.setup()
  File "/usr/local/lib/python3.11/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/lib/python3.11/site-packages/django/apps/registry.py", line 116, in populate
    app_config.import_models()
  File "/usr/local/lib/python3.11/site-packages/django/apps/config.py", line 269, in import_models
    self.models_module = import_module(models_module_name)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/usr/local/lib/python3.11/site-packages/constance/models.py", line 9, in <module>
    raise ImproperlyConfigured("Couldn't find the the 3rd party app "
django.core.exceptions.ImproperlyConfigured: Couldn't find the the 3rd party app django-picklefield which is required for the constance database backend.

Note in my Django settings, CONSTANCE_BACKEND = "constance.backends.redisd.RedisBackend". So no database-related requirements should be needed, ie django-picklefield.

As a temporary workaround, one can install django-picklefield.

System configuration

Cheers and thanks!

sergei-iurchenko commented 1 year ago

when you run pip install https://github.com/jazzband/django-constance/archive/master.zip django-picklefield is automatically installed. It is defined it requirements. I have tested it on my working project and in clean docker container.

root@551dc29fa045:/# pip install https://github.com/jazzband/django-constance/archive/master.zip
Collecting https://github.com/jazzband/django-constance/archive/master.zip
  Downloading https://github.com/jazzband/django-constance/archive/master.zip
     - 227.8 kB 308.3 kB/s 0:00:00
  Preparing metadata (setup.py) ... done
Collecting django-picklefield
  Downloading django_picklefield-3.1-py3-none-any.whl (9.5 kB)
Collecting Django>=3.2
  Downloading Django-4.1.7-py3-none-any.whl (8.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 8.1/8.1 MB 3.5 MB/s eta 0:00:00
Collecting asgiref<4,>=3.5.2
  Downloading asgiref-3.6.0-py3-none-any.whl (23 kB)
Collecting sqlparse>=0.2.2
  Downloading sqlparse-0.4.3-py3-none-any.whl (42 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 42.8/42.8 kB 1.7 MB/s eta 0:00:00
Building wheels for collected packages: django-constance
  Building wheel for django-constance (setup.py) ... done
  Created wheel for django-constance: filename=django_constance-2.9.1-py3-none-any.whl size=62243 sha256=34f87b177f59e2b432ff820bc8d425bdd242b14d5438983bee1532ab4cc86da6
  Stored in directory: /tmp/pip-ephem-wheel-cache-lkq1q7yi/wheels/01/d0/8b/0e3442c5eb151d53447ad8c20de5b3f92c9ada079402e174ae
Successfully built django-constance
Installing collected packages: sqlparse, asgiref, Django, django-picklefield, django-constance
Successfully installed Django-4.1.7 asgiref-3.6.0 django-constance-2.9.1 django-picklefield-3.1 sqlparse-0.4.3
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

[notice] A new release of pip available: 22.3.1 -> 23.0.1
[notice] To update, run: pip install --upgrade pip
root@551dc29fa045:/# 
root@551dc29fa045:/# 
root@551dc29fa045:/# python --version
Python 3.11.1
dtcooper commented 1 year ago

Thanks for the followup. I was using Poetry to install from source, via poetry add git+https://github.com/jazzband/django-constance.git.

To get the latest version, I merely updated (poetry update).

However, completely removing Constance (poetry remove django-constance) and then reinstalling via poetry fixed the problem. Closing.