skorokithakis/django-cloudflare-push

staticfiles module removed in django 3.0

Closed this issue · 2 comments

In Django 3.0 django.contrib.staticfiles.templatetags.staticfiles.static() is removed.

Because of this, in 3.0 w/ django-cloudflare-push, we get a ModuleNotFound error when starting the app.

It looks like we could instead import from here: https://github.com/django/django/blob/master/django/contrib/staticfiles/storage.py#L442

After removing the problematic import statement:

from django.contrib.staticfiles.templatetags import staticfiles

And then changing this line:

storage.staticfiles_storage = staticfiles.staticfiles_storage = storage_factory(collector)()

To this:

storage.staticfiles_storage = storage_factory(collector)()

I got things running.

However, as a solution I don't know how you want to handle it. Perhaps with a try/except on the import statement?

Hmm, yes, a try/except on import is generally the way to go to preserve backwards compatibility. I wish my younger self had commented the code better, as I don't remember why I added that assignment, but it is what it is.

Would you be able to create a PR?

Closed by #8.