Skip to content

Handle removed staticfiles.templatetags in Django 3.0 #1128

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

Merged
merged 1 commit into from
Jan 19, 2019
Merged

Handle removed staticfiles.templatetags in Django 3.0 #1128

merged 1 commit into from
Jan 19, 2019

Conversation

jdufresne
Copy link
Contributor

django.contrib.staticfiles.templatetags.staticfiles was deprecated in Django 2.1:

https://docs.djangoproject.com/en/dev/releases/2.1/#id2

{% load staticfiles %} and {% load admin_static %} are deprecated in favor of {% load static %}, which works the same.

And will be removed in Django 3.0:

https://docs.djangoproject.com/en/dev/releases/3.0/#features-removed-in-3-0

The staticfiles and admin_static template tag libraries are removed.

Catch and ignore an ImportError as the module may not exist. Fixes tests against the Django master branch.

@matthiask
Copy link
Member

matthiask commented Jan 18, 2019

Thank you!

I suspect that changing d.c.s.templatetags.staticfiles isn't even necessary. The staticfiles_storage import in this module is gone since django/django@cf546e1 in 2015, and Django 1.11 was released in 2017.

Since Django version 1.10, commit:
django/django@cf546e1

The module django.contrib.staticfiles.templatetags.staticfiles does not
have the attribute staticfiles_storage. So it doesn't require any
attention in StaticFilesPanel.

Further, the module django.contrib.staticfiles.templatetags.staticfiles
was deprecated in Django 2.1:

https://docs.djangoproject.com/en/dev/releases/2.1/#id2

> {% load staticfiles %} and {% load admin_static %} are deprecated in
> favor of {% load static %}, which works the same.

And will be removed in Django 3.0:

https://docs.djangoproject.com/en/dev/releases/3.0/#features-removed-in-3-0

> The staticfiles and admin_static template tag libraries are removed.

Importing it causes an ImportError on Django 3.0.

Removing the import fixes tests against the Django master branch.
@jdufresne
Copy link
Contributor Author

Thanks, excellent point! That makes the cleanup even easier. In the latest revision I have completely removed django.contrib.staticfiles.templatetags.staticfiles.staticfiles_storage.

@matthiask
Copy link
Member

Thanks!

@matthiask matthiask merged commit da38d0e into django-commons:master Jan 19, 2019
@jdufresne jdufresne deleted the static-panel branch January 20, 2019 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants