简体   繁体   中英

Why isn't this module displaying in the django 1.4 admin interface?

directory stucture

tutorial/tutorials
turotial/tutorial

tutorial/settings.py

 INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
#'domains'
'tutorials'    
)

tutorials/admin.py

from tutorials.models import Tutorial
from django.contrib import admin

admin.site.register(Tutorial)
# Create your views here.

tutorials/models.py

from django.db import models

class Tutorial(models.Model):
    name = models.CharField(max_length=200)
    url = models.CharField(max_length=200)

    def __unicode__(self):
        return self.name

class User(models.Model):
    name = models.CharField(max_length=200)

    def __unicode__(self):
        return self.name

class Country(models.Model):
    name = models.CharField(max_length=200)

    def __unicode__(self):
        return self.name

Few things to help finding the problem:

  • Do you have admin.autodiscover() in your urls.py
  • Have you run syncdb
  • Have you tried to open manage.py shell and import the model to see if there are errors.

您的INSTALLED_APPS设置中可能没有此应用程序的条目。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM