My model has 3 main classes, School, Contest, Participant.

School contains the following fields: school_name, slug, nickname.
Contest contains the following fields: date_scheduled, title, notes.
Participant contains the following fields: contest (foreign key),
school (foreign key), score

I want my Contest admin form to contain a tabular list of 2
participants.  I've added the following line to my ContestAdmin class:
inlines = [ParticipantInline]

But where do I put my ParticipantInline class?  If I put it before the
ContestAdmin class, I get an error that Participant can't be found
because my Participant class comes after the ContestAdmin class.  If I
put it after the ContestAdmin class, I get an error with the
ContestAdmin class with the inlines = [ParticpiantInline]

Here's my complete model.py:

class School(models.Model):
    school_name = models.CharField(max_length=50)
    mascot = models.CharField(max_length=50)

    def __unicode__(self):
        return self.school_name

admin.site.register(School)

class Contest(models.Model):
    date_scheduled = models.DateField()
    title = models.CharField(max_length=50)

    def __unicode__(self):
        return self.title

class ContestAdmin(admin.ModelAdmin):
    inlines = [ParticipantInline]

admin.site.register(Contest, ContestAdmin)

class Participant(models.Model):
    contest = models.ForeignKey(Contest)
    school = models.ForeignKey(School)
    score = models.PositiveIntegerField()

class ParticipantInline(admin.TabularInline):
    model = Participant
    extra = 2
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to