I nedd help - first Django app, part 2 - Admin - Adding related objects

21 views
Skip to first unread message

Rafał Szymański

unread,
Jan 27, 2014, 5:54:31 AM1/27/14
to django...@googlegroups.com
Hello everybody.
I'm Rafał. I just started learnig and I'd like to ask You for little help.
I'm in the part 2 of tutorial - admin, Adding related objects.
I have no three slots for related Choices.
Here is my code.
Thanks in advance for any help.

from django.contrib import admin
from polls.models import Choice, Poll

class ChoiceInline(admin.StackedInline):
    model = Choice
    extra = 3

class PollAdmin(admin.ModelAdmin):
    fieldsets = [
        (None, {'fields': ['question']}),
        ('Date information', {'fields': ['pub_date'], 'classes': ['collapse']}),
    ]
    inline = [ChoiceInline]
    list_display = ('question', 'pub_date', 'was_published_recently')

admin.site.register(Poll, PollAdmin)

Ramiro Morales

unread,
Jan 27, 2014, 8:14:14 AM1/27/14
to django...@googlegroups.com
On Mon, Jan 27, 2014 at 7:54 AM, Rafał Szymański <r.szy...@gmail.com> wrote:
> Hello everybody.
> I'm Rafał. I just started learnig and I'd like to ask You for little help.
> I'm in the part 2 of tutorial - admin, Adding related objects.
> I have no three slots for related Choices.
> Here is my code.
> [snip]
> class PollAdmin(admin.ModelAdmin):
> ...
> inline = [ChoiceInline]

The correct option name here is 'inlines':

inlines = [ChoiceInline]

--
Ramiro Morales
@ramiromorales

Rafał Szymański

unread,
Jan 27, 2014, 8:27:52 AM1/27/14
to django...@googlegroups.com
as usual...

Thank you Ramiro for your effort
Reply all
Reply to author
Forward
0 new messages