0

I have a django model like this.

model.py

class Event(models.Model):
    name = models.CharField(max_length=255)

    def __unicode__(self):
        return self.name

class Location(models.Model):
    name = models.CharField(max_length=255)

    def __unicode__(self):
        return self.name

class Occurrence(models.Model):
    event = models.ForeignKey(Event)
    location = models.ForeignKey(Location)

class TimeSlot(models.Model):
    occurrence = models.ForeignKey(Occurrence)
    start = models.DateTimeField()
    end = models.DateTimeField()

admin.py

class TimeSlotInline(admin.StackedInline):
    model = TimeSlot
    extra = 1

class OccurrenceInline(admin.StackedInline):
    model = Occurrence
    inlines = [TimeSlotInline,]
    extra = 2

class EventAdmin(admin.ModelAdmin):
    inlines = [OccurrenceInline,]

admin.site.register(Event, EventAdmin)
admin.site.register(Location)

I want to display all fields in one page in admin page.(When adding new records.) Multiple inline doesn't work.(Only first inline comes.) Is there any other way to do this ?

Update: Can I do this by modifying admin.py file. Can I add a customized form to inlines of admin.py?

user884624
  • 123
  • 3
  • 7

2 Answers2

1

You can't have nested inlines (inlines within inlines)in the Django admin at the moment

EDIT

Nested inlines in the Django admin?

Community
  • 1
  • 1
Timmy O'Mahony
  • 53,000
  • 18
  • 155
  • 177
  • Thanks pastylegs, I saw it before, but I couldnt apply that patch to django 1.3. Can I overcome this issue by adding a form (by modiying administration panel)? Or do you have any solution either? – user884624 Nov 12 '11 at 17:40
0

It's supposed to be:

class OccurrenceInline(admin.StackedInline):
    model = Occurrence
    extra = 2

class EventAdmin(admin.ModelAdmin):
    inlines = [OccurrenceInline, TimeSlotInline,]
dan-klasson
  • 13,734
  • 14
  • 63
  • 101