目录结构
tutorial/tutorials
turotial/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'
)
教程/ admin.py
from tutorials.models import Tutorial
from django.contrib import admin
admin.site.register(Tutorial)
# Create your views here.
教程/ 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
答案 0 :(得分:1)
很少有事情可以帮助您找到问题:
admin.autodiscover()
吗?
manage.py shell
并导入模型以查看是否存在错误。答案 1 :(得分:0)
您可能在此应用的INSTALLED_APPS设置中没有条目。