python - django admin如何显示多个模块?
大家讲道理
大家讲道理 2017-04-17 17:59:50
0
2
254

如何在admin后台显示的时候,显示成多个模块?

目前我的代码

class LevelAdmin(admin.ModelAdmin):
    list_display = ['level1', 'level2']

class BaseUrlAdmin(admin.ModelAdmin):
    list_display = ['package_url', 'package_url_desc', "package_url_tag"]
    
admin.site.register(LevelForUrl, LevelAdmin)
admin.site.register(BaseUrl, BaseUrlAdmin)

如上图所示,admin.py里如何写才能达到以上效果?

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(2)
PHPzhong

I was too busy the past few days, so I finally researched it. It turns out it is very simple. Please forgive my ignorance. . .
Answer it yourself, the idea is:

  • Create a new app, epython manage.py startapp proname;

  • Then build the Model in the models of this app;

  • Register this model in admin.py in the newly created app;

  • Sync python manage.py makemigrations \ python manage.py migrate

  • Just restart your service

The effect is as follows:

刘奇

You may need to implement an AdminSite yourself, and then register(.......,site=)

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template