我是Django的新手,我有这样的简单模型。
RewriteRule ^http:\/\/example.com\/([^\?.]*)[\?]?([^/]*)$ http://example.com/page\.php?url=$1&$2
在网址中,
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)
我检查了stackoverflow,他们说应该删除自动发现。但如果我删除,我会看到这样的。我该怎么办才能在管理员中显示我的模型?
答案 0 :(得分:1)
答案 1 :(得分:1)
执行此操作
from django.contrib import admin
from .models import Todo, News
# Register your models here.
admin.site.register(Todo)
admin.site.register(News)
您的应用可能未在INSTALLED_APPS
中注册,如果它发现您的应用失败并且没有出错