-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Circular dependency in finding static files urls (for manifested files) #15
Comments
Some further discussion of the same issue in https://code.djangoproject.com/ticket/21221 |
Thanks @thclark for the analysis, I think have the same issue, which makes it impossible to use the icons in my project together with whitenoise. A workaround is simply not possible, right? Since I need to use sth. like whitenoise in my setup with Django 3, I cannot use this package. The fix seems to be simple, but I'm not sure how to write a unit test for it. How can I force manifested static files collection in a test? Could this be done by just setting
in the settings in the test and then calling 'collectstatic'? |
Hmm. I don't know actually. Yes, I guess so! Even if untested in this particular scenario it'd be a helpful fix to have (I'm still in the dark ages on font awesome 4!) |
@mcrot this might be of help; use |
There seem to be no tests so far, so maybe I should not be holier than the pope. I've created a PR with your fix, but I haven't tested it yet. However, I will also try the package django-icons as an alternative which is using a CDN. |
Thanks for the pointer to |
I think django-fontawesome-5 is incompatible with manifested static files collection (e.g. using whitenoise to efficiently cache and serve).
This is because the
css_admin
is not lazily evaluated atwidgets.py, line 9
:This gets called even when invoking management commands, like
collectstatic
. Of course, if you are compressing and/or manifesting your static files (e.g. like using a CDN or whitenoise) the call tostatic()
(which gets their new, hashed, name) will check for the presence of the file in the manifest... which isn't there, because you haven't run collectstatic yet!Without such manifesting, it's not a problem because django won't run the check for the presence of the modified filename.
Basically, you can't call
get_css_admin()
until such a time as you can reasonably expect thatcollectstatic
will have completed. I think the fix is as simple as moving the call to theMedia
class below.Here's a traceback:
The text was updated successfully, but these errors were encountered: