我不明白为什么当我在管理面板中创建 Post 模型时,它没有显示在我的服务器上的管理面板中
这里是代码admin.py
from django.contrib import admin
from .models import Post
admin.site.register(Post)
这里是代码models.py
from django.db import models
class Post(models.Model):
title = models.CharField(max_length=200)
author = models.ForeignKey(
'auth.User',
on_delete=models.CASCADE,
)
body = models.TextField()
def __str__(self):
return self.title`
很高兴得到您的任何建议和帮助
答案 0 :(得分:0)
在setting.py文件中添加用户应用程序
INSTALLED_APPS = [
'corsheaders',
'django.contrib.admin',
'django.contrib.auth',
'dynamic_preferences.users.apps.UserPreferencesConfig',
'dynamic_preferences',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'blog',
]
然后进行迁移并迁移您的模型。我认为它适合你。