Reputation: 46158
Imagine this model:
class ExercisePart(models.Model):
exercise = models.ForeignKey(Exercise)
sequence = models.IntegerField()
class Meta:
unique_together = (('exercise', 'sequence',),)
class Exercise(models.Model):
name = models.CharField(max_length=15)
From the admin interface I'd like to be able to create/link ExercisePart
s through the Exercise
page. I'd like to do that because I wish to avoid having to go on another page each time I want to add an ExercisePart
s.
Is it possible ? How can I do that ?
Upvotes: 0
Views: 468
Reputation: 4446
You're looking for the inline admin feature.
admin.py
class ExercisePartInline(admin.TabularInline):
model = ExercisePart
class ExerciseAdmin(admin.ModelAdmin):
inlines = [ExercisePartInline]
Upvotes: 2