sehmaschine / django-grappelli

A jazzy skin for the Django Admin-Interface (official repository).
http://www.grappelliproject.com
Other
3.77k stars 657 forks source link

3.0.7 crashes with ManifestStaticFilesStorage #1022

Closed atodorov closed 1 year ago

atodorov commented 1 year ago
$ ./manage.py collectstatic --clear --link --noinput

... skip ...

Post-processing 'grappelli/jquery/ui/jquery-ui.min.css' failed!

Traceback (most recent call last):
  File "/Kiwi/manage.py", line 12, in <module>
    execute_from_command_line(sys.argv)
  File "/venv/lib64/python3.9/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/venv/lib64/python3.9/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/venv/lib64/python3.9/site-packages/django/core/management/base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/venv/lib64/python3.9/site-packages/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
  File "/venv/lib64/python3.9/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 209, in handle
    collected = self.collect()
  File "/venv/lib64/python3.9/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 154, in collect
    raise processed
  File "/venv/lib64/python3.9/site-packages/django/contrib/staticfiles/storage.py", line 377, in _post_process
    content = pattern.sub(converter, content)
  File "/venv/lib64/python3.9/site-packages/django/contrib/staticfiles/storage.py", line 254, in converter
    hashed_url = self._url(
  File "/venv/lib64/python3.9/site-packages/django/contrib/staticfiles/storage.py", line 187, in _url
    hashed_name = hashed_name_func(*args)
  File "/venv/lib64/python3.9/site-packages/django/contrib/staticfiles/storage.py", line 427, in _stored_name
    cache_name = self.clean_name(self.hashed_name(name))
  File "/venv/lib64/python3.9/site-packages/django/contrib/staticfiles/storage.py", line 148, in hashed_name
    raise ValueError(
ValueError: The file 'grappelli/jquery/ui/"images/ui-icons_555555_256x240.png"' could not be found with <django.contrib.staticfiles.storage.ManifestStaticFilesStorage object at 0x7f3a62b27fa0>.

Notice the extra double quotes in grappelli/jquery/ui/"images/ui-icons_555555_256x240.png" !

I believe this comes from the comment placed at the top of jquery-ui.css, possibly a few other files: https://github.com/sehmaschine/django-grappelli/blob/master/grappelli/static/grappelli/jquery/ui/jquery-ui.css#L4C4-L4C4

Few things:

1) It would be great if we can have a test job with

STATICFILES_STORAGE = \
    'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'

I may be able to contribute a pull request to that

2) Not sure how to fix the issue, probably the easiest way is to remove the offending lines from the jQuery source files.

victorvaldez5 commented 1 year ago

Looks like I opened a similar issue to this one a little bit after you did. My work around for this was to copy the files that break collectstatic into my static directory and removing the comments that you mentioned. So you're right that removing them would solve the problem.

sehmaschine commented 1 year ago

I'm happy to check a PR! But I'm not so sure about changing the code of a 3rd-party app since we'll run into this with future jquery-ui updates as well (but ok, a test case should warn us then).

LucidDan commented 1 year ago

I ran into this as well. I've pinned to 3.0.6 for now, while I decide what to do in my project.

FWIW I think this is a relatively well known and long standing issue in Django...without a good solution yet, either...see https://code.djangoproject.com/ticket/21080

sehmaschine commented 1 year ago

merged with master. please give it a test and let me know if it works as expected (it works fine with my setup/tests).

vaanevre commented 1 year ago

Hi. The new version after the fix works fine, I just checked on my project. At the moment, unfortunately, the latest version (3.0.7) is broken, it would be nice to override it with this fix.

P.S. So far I'm using 3.0.6