0

I am getting an Indention Error. This code is straight from the django first tutorial.

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)
3
  • 2
    I guess it also tells you the line number that throw this error. Commented Jul 30, 2011 at 8:10
  • 2
    check if you have any tab and whitespace mix, that's usually the problem. Commented Jul 30, 2011 at 10:41
  • Shit, I am really sorry. Actually i was editing the file in notepad++ and in that it was showing alright, but when i opened the file in IDLE, the inlines = [ChoiceInline] code was intended. Commented Jul 30, 2011 at 11:35

1 Answer 1

2

Works fine for me on python2.7, make sure you didn't mix tabs and spaces in your actual code. There is also an extra comma at the end of the second line in fieldsets, but that should be fine in python.

Sign up to request clarification or add additional context in comments.

1 Comment

The comma is fine and actually encouraged in Python, so that new lines can be added to the list without having to modify existing lines.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.