Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django: 'LeagueAdmin.inlines' must be 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 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.

like image 300
Yousuf Jawwad Avatar asked Jan 27 '12 20:01

Yousuf Jawwad


2 Answers

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

inlines = [TeamsInLeague]

or

inlines = (TeamsInLeague,)
like image 178
Ismail Badawi Avatar answered Sep 21 '22 21:09

Ismail Badawi


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].

like image 21
bouteillebleu Avatar answered Sep 19 '22 21:09

bouteillebleu