简体   繁体   English

django python代码中的缩进错误

[英]Indention Error in django python code

I am getting an Indention Error. 我收到了Indention错误。 This code is straight from the django first tutorial. 这段代码直接来自django第一篇教程。

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)

Works fine for me on python2.7, make sure you didn't mix tabs and spaces in your actual code. 在python2.7上对我工作正常,请确保您没有在实际代码中混合制表符和空格。 There is also an extra comma at the end of the second line in fieldsets, but that should be fine in python. 在fieldsets的第二行末尾还有一个额外的逗号,但在python中应该没问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM