Reputation: 210352
I'm trying to get the Django admin interface to display objects from my database, but whenever I click the name of a model, I come across an error:
/myAppName/myModelName/
I don't understand: Why do I need any templates for the admin interface in the first place?
I thought the admin interface was already pre-made for us, and that we didn't need any custom HTML for it... right?
settings.py
:
ADMIN_MEDIA_PREFIX = '/admin_media/'
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.contenttypes',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
'django.contrib.admindocs',
'my_app_name',
)
TEMPLATE_DIRS = (
'<project_path>/templates',
'<django_path>/v1_2/contrib/admin/templates',
)
admin.py
:
from my_app.models import MyModel
from django.contrib import admin
admin.site.register(MyModel)
models.py
:
from django.db import models
class MyModel(models.Model):
#my fields here
Upvotes: 2
Views: 2813
Reputation: 210352
OMG, this is so tricky! I just ran into the solution by pure chance:
The problem was that I was going into the admin interface with a URL of the form:
127.0.0.1:8000/admin
while in fact I should have said:
127.0.0.1:8000/admin/
that solved the issue. (!)
Upvotes: 1