Here is my code:
from League.models import Leagues
from League.models import Team
from django.contrib import admin
class TeamsInLeague(admin.StackedInline):
model = Team
extra = 1
class LeagueAdmin(admin.ModelAdmin):
fields = ['LeagueName']
inlines = TeamsInLeague
admin.site.register(Leagues,LeagueAdmin)
it gives me the error:
'LeagueAdmin.inlines' must be a list or tuple.
It works fine when I remove inlines = TeamsInLeague
I am following the tutorial, not to the word, but trying to solve my own problem.
The error is pretty clear -- inlines
should be a list or tuple, not a class. Use
inlines = [TeamsInLeague]
or
inlines = (TeamsInLeague,)
The Django admin reference page has an example of a model with one inline item: even in that case, you need to make inlines
a list.
So instead of what you have currently, use inlines = [TeamsInLeague]
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With