Skip to content
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

Django-rest-swagger broken after Django 3 #395

Closed
paalbra opened this issue Feb 3, 2020 · 7 comments
Closed

Django-rest-swagger broken after Django 3 #395

paalbra opened this issue Feb 3, 2020 · 7 comments
Labels
bug Something isn't working

Comments

@paalbra
Copy link
Contributor

paalbra commented Feb 3, 2020

/docs/ produces:

'staticfiles' is not a registered tag library. Must be one of: admin_list admin_modify admin_urls cache i18n l10n log rest_framework static tz

The staticfiles and admin_static template tag libraries are removed.

https://docs.djangoproject.com/en/3.0/releases/3.0/

Django-rest-swagger is deprecated. We probably have to move to something else.

marcgibbons/django-rest-swagger#815

@paalbra paalbra added the bug Something isn't working label Feb 3, 2020
@Angy
Copy link

Angy commented Mar 16, 2020

Doesn't work with Django 2.2.10 either

@FairTraxx
Copy link

FairTraxx commented Jun 10, 2020

The fix is simple, navigate to index.html (AppData\Local\programs\python\python38\lib\site-packages\rest-framework-swagger\index.html)
change second line {% load staticfiles %}
to {% load static %}
Should then work

@FairTraxx
Copy link

Update if you're still stumbling upon this error the above fix will only fix it locally, fixing this on a server is painful.
Instead, just use a completely different Swagger generator i suggest drf-yasg

@oyvindhagberg
Copy link
Contributor

@FairTraxx Thanks, I will take a look at drf-yasg.

@mbakke
Copy link
Contributor

mbakke commented Sep 8, 2020

The django-rest-swagger dependency was removed with #411.

@mbakke mbakke closed this as completed Sep 11, 2020
@GourishettySairam
Copy link

The fix is simple, navigate to index.html ((localtion of ur pip package installation)\Lib\site-packages\rest_framework_swagger\templates\rest_framework_swagger\index.html)
change second line {% load staticfiles %}
to {% load static %}
Should then work

@taahamultani
Copy link

Another Fix i found useful is this.

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [BASE_DIR / 'templates'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
'libraries': {
'staticfiles': 'django.templatetags.static',
}
},
},
]

Include template.libraries as staticfiles so that you dont have to change the index.html inside env.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants