0

我对 django 1.5 有一些问题,回溯是 'MyUserAdmin.fieldsets[3][1]['fields']' refers to field 'l' that is missing from the form.

代码是

fieldsets = (
        (None, {'fields':('name', 'password')}),
        ('User info', {'fields':('email',)}),
        ('Permissions',{'fields':('is_admin',)}),
        ('Important dates',{'fields':('last_login,')}),
        )

class MyUser(AbstractBaseUser, PermissionsMixin):
    name = models.CharField("姓名", max_length=20, unique=True, db_index=True)
    consumption= models.DecimalField("菜品总消费", max_digits=5, decimal_places=0)
    email = models.EmailField(max_length=75)
    times = models.DecimalField("消费次数", max_digits=4, decimal_places=0)
    USERNAME_FIELD = 'name'
    REQUIRED_FIELDS = ['email', ]
    is_active = models.BooleanField(default=True)
    is_admin = models.BooleanField(default=False)
    @property
    def is_staff(self):
        return self.is_admin
    def __unicode__(self):
        return unicode(self.nam

我无法修复它,我不明白“字段'l'”的意思

4

1 回答 1

0

如果这确实是您的字段集声明,那么问题是一个错字 - 您的引号内有逗号last_login。它在字符串上进行迭代,last_login,就好像它是字段名称的元组一样。

于 2013-05-08T04:24:40.750 回答