gradam / django-better-admin-arrayfield

Better widget for Django ArrayField in admin
MIT License
215 stars 34 forks source link

Missing staticfiles manifest entry #13

Closed sergei-maertens closed 5 years ago

sergei-maertens commented 5 years ago

Description

Same as #5, literally, but with debug output.

Running collectstatic crashes because of static() call in the admin mixin. The mixin is imported in the admin.py modules, which are autodiscovered during django startup time.

What I Did

Setting:

STATICFILES_STORAGE = "django.contrib.staticfiles.storage.ManifestStaticFilesStorage"

python src/manage.py collectstatic --noinput
Traceback (most recent call last):
  File "src/manage.py", line 24, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 357, in execute
    django.setup()
  File "/usr/local/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/lib/python3.7/site-packages/django/apps/registry.py", line 122, in populate
    app_config.ready()
  File "/usr/local/lib/python3.7/site-packages/django/contrib/admin/apps.py", line 24, in ready
    self.module.autodiscover()
  File "/usr/local/lib/python3.7/site-packages/django/contrib/admin/__init__.py", line 26, in autodiscover
    autodiscover_modules('admin', register_to=site)
  File "/usr/local/lib/python3.7/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.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/app/src/openzaak/components/catalogi/admin/__init__.py", line 2, in <module>
    from .catalogus import *  # noqa
  File "/app/src/openzaak/components/catalogi/admin/catalogus.py", line 10, in <module>
    from .zaken import ZaakTypeAdmin
  File "/app/src/openzaak/components/catalogi/admin/zaken.py", line 4, in <module>
    from django_better_admin_arrayfield.admin.mixins import DynamicArrayMixin
  File "/usr/local/lib/python3.7/site-packages/django_better_admin_arrayfield/admin/mixins.py", line 4, in <module>
    class DynamicArrayMixin:
  File "/usr/local/lib/python3.7/site-packages/django_better_admin_arrayfield/admin/mixins.py", line 5, in DynamicArrayMixin
    class Media:
  File "/usr/local/lib/python3.7/site-packages/django_better_admin_arrayfield/admin/mixins.py", line 6, in Media
    js = (static("js/min/django_better_admin_arrayfield.min.js"),)
  File "/usr/local/lib/python3.7/site-packages/django/templatetags/static.py", line 167, in static
    return StaticNode.handle_simple(path)
  File "/usr/local/lib/python3.7/site-packages/django/templatetags/static.py", line 118, in handle_simple
    return staticfiles_storage.url(path)
  File "/usr/local/lib/python3.7/site-packages/django/contrib/staticfiles/storage.py", line 153, in url
    return self._url(self.stored_name, name, force)
  File "/usr/local/lib/python3.7/site-packages/django/contrib/staticfiles/storage.py", line 132, in _url
    hashed_name = hashed_name_func(*args)
  File "/usr/local/lib/python3.7/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 'js/min/django_better_admin_arrayfield.min.js'
sergei-maertens commented 5 years ago

According to https://docs.djangoproject.com/en/2.2/topics/forms/media/#paths-in-asset-definitions you don't need the static call yourself, but Django will perform it if django.contrib.staticfiles is installed. So removing the call should fix this.

I'll verify this theory and contribute a PR if it works.