I\'m following Django\'s official Tutorial 2 but for some reason cannot create an admin site despite following all the steps correctly to my understanding.
This is t
Inheriting a Django-application from an experienced magician, I wanted to understand the model by looking at it through Django-admin. As the app's model was not in Admin yet, I created an admin.py
and ran into various problems. I tried All-Of-The-Above(TM) and found this:
I got the paths confused. I put the admin.py
file into the wrong directory. If you have something like .../app/app/app/app/app...
make sure you know which app
needs to hold the admin.py
. I figured that out by putting crap into the file and notice, that it would not crash. Hence 'crap' was not executed and something was wrong with the file. Fixed.
TemplateDoesNotExist
on 'admin/index.html' The app's settings.py
was configured to only run django.template.backends.jinja2.Jinja2
as TEMPLATES BACKEND. But Admin needs the standard django.template.backends.django.DjangoTemplates
to make it work. I read, that it was possible to have two template-engines configured. I copied the standard-block from a different app. Fixed.
TemplateDoesNotExist
on 'admin/widgets/related_widget_wrapper.html' While Admin was now working, looking at individual objects was still broken. I searched for the missing template and found it well in place. Changing anything on my TEMPLATES
setting would not improve anything. I manually inserted paths in 'DIRS': []
, changed options, deleted the Jinja backend, nothing. It felt like was changing the wrong file again. Using the debugger, I found that even without configuring Jinja, it would still run Jinja. Finally, in settings.py
, I spotted this:
FORM_RENDERER = 'django.forms.renderers.Jinja2'
and commenting it out got Admin going.
Not sure tho what it does with the rest of the application but for learning it's okay.