Sunday, January 10, 2010

Inline Admin and ForeignKey

Hi,

I have a blog model and would like to be able to add an arbitrary
number of event dates to it (i.e. turn a blog post into an event
announcement). For that I use

class Event(models.Model):
entry = models.ForeignKey(Entry)
begin_date = models.DateTimeField(default=datetime.datetime.now)
end_date = models.DateTimeField(default=datetime.datetime.now)

I hope this is good so far.
What I would like to happen is to be able to add those events inline -
inside an Entry editing page in the admin interface:

class EventInline(generic.GenericTabularInline):
model = Event
max_num = 1 #TODO: Fix this


class EntryAdmin(admin.ModelAdmin):
prepopulated_fields = { 'slug': ['title'] }
inlines = [ EventInline ]

But in the Entry admin page I see three blocks of begin_date and
end_date. No option to edit/delete them, or add a new one. The three
are basically static.

What am I doing wrong?

Thanks for any ideas!

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate