[Fixed]-Problems with TabularInline in Django Admin

1👍

but it also has several blank records (which I assume are related to
the campus records for other schools).

Those “blank” records are for adding new campuses to the school. You can use the “extra” attribute on your CampusInline to control the number of blank lines.

If I add “unique=True” to the foreign key (as shown in the model
above), the blank records disappear and all looks good. Unfortunately,
I also loos the link at the bottom of the inline to add a new campus.

If you add “unique” to the “school” field, that would mean that a school could only appear once in the campus table. Which doesn’t (usually) make much sense for a foreign key.

Leave a comment