Вопрос

So I'm having a problem with my code, the django beginner tutorial on their website. I am pretty new to programming and I looked at a couple of the other NameError posts on here and the either pertained to installing python, or were a lot more complex that my skill level.

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']}),
            ]
    inlines = [ChoiceInLine]

admin.site.register(Poll, PollAdmin)

NameError: name 'ChoiceInLine' is not defined

Now I know I have not defined StackedInline anywhere like its a variable, I just assumed it was a prefabricated module that calls a django process from somewhere. Where did I mess up? Excuse the extreme newbiness.

Это было полезно?

Решение

Python variable names are case-sensitive.

Replace:

inlines = [ChoiceInLine]

with (watch L=>l):

inlines = [ChoiceInline]
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top