[英]Django - admin.py for multiple apps in a single django project
I have a Django project that has 2 apps - a blog app and a tutorials app. 我有一个包含2个应用程序的Django项目-一个博客应用程序和一个教程应用程序。 I just completed the blog app and it has the admin.py
for registering the models like so: 我刚刚完成了博客应用程序,它具有用于注册模型的admin.py
,如下所示:
admin.site.register(Blog, BlogAdmin)
admin.site.register(Category, CategoryAdmin)
I just started working on the tutorials app and wrote the models and created the admin.py
within it. 我刚刚开始使用教程应用程序,并编写了模型并在其中创建了admin.py
。 It looks as follows: 它看起来如下:
admin.site.register(Tutorial, tutorialAdmin)
admin.site.register(tutType, tutTypeAdmin)
The models have been imported. 模型已导入。 However, when I run python manage.py syncdb
and then python manage.py runserver
, I do not find the new models in the admin section of the site ( 127.0.0.1:8000/admin
). 但是,当我先运行python manage.py syncdb
和python manage.py runserver
,在站点的admin部分( 127.0.0.1:8000/admin
)中找不到新模型。
Should I move the admin.py
outside both the apps and make it a single file which registers all the models of the different apps? 我是否应该将admin.py
两个应用程序之外,并使其成为一个文件,用于注册不同应用程序的所有模型? Or is there some other step that I am missing out on? 还是我错过了其他步骤?
@i.h4d35 I think DivinusVox is right. @ i.h4d35我认为DivinusVox是正确的。 Try to add your new app in INSTALLED_APPS in the settings.py and it should be solved. 尝试将新应用添加到settings.py中的INSTALLED_APPS中,应该可以解决。 Please check admin info from Django official website . 请从Django官方网站查看管理信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.