[Fixed]-Django admin with inlines, 1 model with 2 foreigns keys to 2 different models

1👍

Update

The code I posted earlier was wrong! I didn’t read your models too carefully. Sorry about that.

If you want to create CharacterSeries and CharacterUniverse while you create/edit the Character, you could do this:

from django.contrib import admin
from .models import Character, CharacterUniverse, CharacterSeries

# No need to define `ModelAdmin` classes

admin.site.register(Character)
admin.site.register(CharacterUniverse)
admin.site.register(CharacterSeries)

The code above will give you a + (plus) sign after the universe and series fields. This will help you create CharacterUniverse and CharacterSeries objects on the fly.

👤xyres

Leave a comment