Thanks, you're right... was posting this late at night while
experimenting and copied the experimental version... The way it looks
now is this:

class EventInline(admin.TabularInline):
    model = Event

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

Now, I've realized it works, but it always shows at least 3 Event
items in an admin page which is slightly annoying... I'd rather have
none with an option to add more if the user wants to.



On Jan 11, 2:26 pm, Daniel Roseman <dan...@roseman.org.uk> wrote:
> On Jan 11, 12:43 am, Igor <igor.rubinov...@gmail.com> wrote:
>
>
>
> > 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!
>
> On Jan 11, 12:43 am, Igor <igor.rubinov...@gmail.com> wrote:
>
>
>
> > 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!
>
> Why are you using generic.GenericTabularInline rather than
> admin.TabularInline? I don't know if that's the cause of your problem,
> but it's bound to lead to some issues since you don't have a generic
> relation.
> --
> DR.
-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to