看看代码——
模型.py
from __future__ import unicode_literals
from django.db import models
from django.contrib.auth.models import User
class Event(models.Model):
_id = models.AutoField(primary_key=True)
name = models.CharField(max_length=100)
primary_link = models.URLField(max_length=400, null=True, blank=True)
def __unicode__(self):
return self.name
class EventMedia(models.Model):
event = models.ForeignKey(Event)
description = models.TextField(null=True, blank=True)
media = models.FileField(null=True, blank=True, upload_to="event_media")
def __unicode__(self):
return self.event.name
和
管理员.py
from django.contrib import admin
from mainapi.models import *
from nested_inline.admin import NestedStackedInline, NestedModelAdmin
class EventMediaInline(NestedStackedInline):
model = EventMedia
extra = 1
class coreEventsAdmin(NestedModelAdmin):
inlines = (EventMediaInline,)
admin.site.register(Event, coreEventsAdmin)
现在管理站点上发生的事情是,我能够在 Event 模型上看到 EventMedia 模型的内联块,但无法看到在 Event 模型中添加新的 Event Media 内联块的选项。有谁知道这可能是什么原因?