Must have a list or tuple

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 an error

'LeagueAdmin.inlines' must be a list or tuple.

it works fine when I delete "inlines = TeamsInLeague"

I follow the guide, not the word, but try to solve my own problem.

Thankyou.

+4
source share
2 answers

The error is pretty clear - inlines should be a list or tuple, not a class. Use

 inlines = [TeamsInLeague] 

or

 inlines = (TeamsInLeague,) 
+13
source

The Django admin help page contains an example model with one built-in element: even in this case, you need to make an inlines list.

So, instead of what you have, use inlines = [TeamsInLeague] .

+2
source

Source: https://habr.com/ru/post/1393427/


All Articles