-
-
Notifications
You must be signed in to change notification settings - Fork 494
[BUG] Django Ninja docs fails when django.contrib.auth is not in INSTALLED_APPS #1438
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
Comments
Hi @devjerry0 would be nice if you provide a traceback, I assume you have something like this: ...
File "/private/tmp/dislip_contradictiveness/.venv/lib/python3.12/site-packages/django/template/context.py", line 259, in bind_template
context = processor(self.request)
^^^^^^^^^^^^^^^^^^^^^^^
File "/private/tmp/dislip_contradictiveness/.venv/lib/python3.12/site-packages/django/contrib/auth/context_processors.py", line 60, in auth
from django.contrib.auth.models import AnonymousUser
File "/private/tmp/dislip_contradictiveness/.venv/lib/python3.12/site-packages/django/contrib/auth/models.py", line 39, in <module>
class Permission(models.Model):
File "/private/tmp/dislip_contradictiveness/.venv/lib/python3.12/site-packages/django/db/models/base.py", line 136, in __new__
raise RuntimeError(
RuntimeError: Model class django.contrib.auth.models.Permission doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS. if so you need to remove TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.request',
# 'django.contrib.auth.context_processors.auth', # <-------------- !!!!!!!!!!!!!!!!
'django.contrib.messages.context_processors.messages',
],
},
},
] |
@vitalik thanks for the quick response! Thank you, worked! btw my workaround was creating a hacky custom view ^^
|
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
When trying to access the Django Ninja auto-generated docs at
/api/v1/docs
, an error occurs ifdjango.contrib.auth
is not in INSTALLED_APPS:This is problematic for projects that intentionally avoid using Django's auth system:
docs_url=None
or create a custom view.Expected Behavior
Django Ninja's documentation should work without requiring django.contrib.auth to be in INSTALLED_APPS. Ideally:
Steps to Reproduce
Setup
You can quickly get this by runninng in
./manage.py shell
this line:import django; import pydantic; import ninja; django.__version__; ninja.__version__; pydantic.__version__
Versions (please complete the following information):
The text was updated successfully, but these errors were encountered: