【发布时间】:2016-04-01 10:15:57
【问题描述】:
每个人,,我正在阅读一本Django练习书,,我在admin.py中看到了一个代码“model = Thing”,,,但是,当我删除“model = Thing”时,,网络程序仍然可以运行,管理站点看起来没有区别??,这段代码是什么意思?如果没有它会发生什么?我的 models.py 类是 Thing
admin.py
from django.contrib import admin
from collection.models import Thing
class ThingAdmin(admin.ModelAdmin):
model = Thing #if I remove this code, the program still can run,,why need this code
list_display = ('name', 'description',)
prepopulated_fields = {'slug': ('name',)}
admin.site.register(Thing, ThingAdmin)
模块.py
from django.db import models
class Thing(models.Model):
name = models.CharField(max_length=255)
description = models.TextField()
slug = models.SlugField(unique=True)
【问题讨论】:
-
只有
InlineModelAdmin- docs.djangoproject.com/en/1.9/ref/contrib/admin/…才需要 -
感谢您的回答
标签: django django-admin