目前我的代码
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里如何写才能达到以上效果?
PHPz2017-04-17 18:01:50
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:
怪我咯2017-04-17 18:01:50
You may need to implement an AdminSite yourself, and then register(.......,site=)