jmrivas86 / django-json-widget

An alternative widget that makes it easy to edit the new Django's field JSONField (PostgreSQL specific model fields)
MIT License
440 stars 88 forks source link

Collectstatic broken in 0.3.0+ #33

Closed D3X closed 4 years ago

D3X commented 4 years ago

Description

After upgrading from 0.2.0 collectstatic fails with an exception when STATICFILES_STORAGE is set to ManifestStaticFilesStorage.

What I Did

python manage.py collectstatic --noinput
Traceback (most recent call last):
  File "manage.py", line 35, in <module>
    execute_from_command_line(sys.argv)
  File "/home/circleci/project/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/home/circleci/project/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute
    django.setup()
  File "/home/circleci/project/venv/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/circleci/project/venv/lib/python3.6/site-packages/django/apps/registry.py", line 122, in populate
    app_config.ready()
  File "/home/circleci/project/venv/lib/python3.6/site-packages/django/contrib/admin/apps.py", line 24, in ready
    self.module.autodiscover()
  File "/home/circleci/project/venv/lib/python3.6/site-packages/django/contrib/admin/__init__.py", line 26, in autodiscover
    autodiscover_modules('admin', register_to=site)
  File "/home/circleci/project/venv/lib/python3.6/site-packages/django/utils/module_loading.py", line 47, in autodiscover_modules
    import_module('%s.%s' % (app_config.name, module_to_search))
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/circleci/project/venv/lib/python3.6/site-packages/suit/admin.py", line 192, in <module>
    from cms.admin.forms import PageForm
  File "/home/circleci/project/cms/admin.py", line 5, in <module>
    from core.admin.filters import RawIDListFilter
  File "/home/circleci/project/core/admin/__init__.py", line 3, in <module>
    from core.admin.models import (
  File "/home/circleci/project/core/admin/models/__init__.py", line 21, in <module>
    from core.admin.widgets import JSONEditorWidget
  File "/home/circleci/project/core/admin/widgets.py", line 4, in <module>
    from django_json_widget.widgets import (
  File "/home/circleci/project/venv/lib/python3.6/site-packages/django_json_widget/widgets.py", line 8, in <module>
    class JSONEditorWidget(forms.Widget):
  File "/home/circleci/project/venv/lib/python3.6/site-packages/django_json_widget/widgets.py", line 9, in JSONEditorWidget
    class Media:
  File "/home/circleci/project/venv/lib/python3.6/site-packages/django_json_widget/widgets.py", line 10, in Media
    css = {'all': (static('dist/jsoneditor.min.css'), )}
  File "/home/circleci/project/venv/lib/python3.6/site-packages/django/templatetags/static.py", line 167, in static
    return StaticNode.handle_simple(path)
  File "/home/circleci/project/venv/lib/python3.6/site-packages/django/templatetags/static.py", line 118, in handle_simple
    return staticfiles_storage.url(path)
  File "/home/circleci/project/venv/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py", line 153, in url
    return self._url(self.stored_name, name, force)
  File "/home/circleci/project/venv/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py", line 132, in _url
    hashed_name = hashed_name_func(*args)
  File "/home/circleci/project/venv/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py", line 420, in stored_name
    raise ValueError("Missing staticfiles manifest entry for '%s'" % clean_name)
ValueError: Missing staticfiles manifest entry for 'dist/jsoneditor.min.css'

Suspected

I believe the issue was introduced by 42b2c7668659ea85eb22d5bd64ee89656b0d70a5. According to django documentation, Media class should use relative paths instead of resolving them with static().