我是Django的新手,我有這樣的簡單模型。Django在管理中不顯示模型
from django.db import models
from django.contrib.auth.models import User
class Todo(models.Model):
owner = models.ForeignKey(User)
description = models.CharField(max_length=30)
done = models.BooleanField()
updated = models.DateTimeField(auto_now_add=True)
class News(models.Model):
title = models.TextField(max_length=400000)
description = models.TextField(max_length=400000)
created = models.DateTimeField(editable=False)
modified = models.DateTimeField()
def save(self, *args, **kwargs):
''' On save, update timestamps '''
if not self.id:
self.created = timezone.now()
self.modified = timezone.now()
return super(User, self).save(*args, **kwargs)
在URL,
from django.conf.urls import patterns, include, url
from todo import views
from rest_framework import viewsets, routers
from django.contrib import admin
router = routers.DefaultRouter()
admin.autodiscover()
urlpatterns = patterns('',
url(r'^admin/', admin.site.urls),
url(r'^', include(router.urls)),
)
我檢查計算器和他們說的自動發現應該被刪除。但如果我刪除,我看到這樣。我該怎麼做,以便我的模型在管理中顯示?
你們搖滾。謝謝 –