我做了一个模型(models.py):
class opetest(models.Model):
name = models.CharField(max_length=200)
author = models.ForeignKey(User, related_name='author')
description = models.TextField(u'Test description', help_text = u'Some words about quiz')
pub_date = models.DateTimeField('date published', blank=False)
vacancies = models.ManyToManyField(Vacancy, blank=True)
students = models.ManyToManyField(User, blank=True, related_name='opetests') #This field I want to edit on "User change page"
estimate = models.IntegerField(default = 0, help_text = u'Estimate time in hours. \'0\' - unlimited')
然后我尝试添加内联块以允许在“更改用户”页面(admin.py)上分配opetest
:
class ProfileAdmin(UserAdmin):
filter_horizontal = ('opetests',)
admin.site.unregister(User)
admin.site.register(User, ProfileAdmin)
我得到了一个错误:
'ProfileAdmin.filter_horizontal' refers to field 'opetests' that is missing from model 'User'.
我想在更改用户页面上显示类似于组的操作测试。我该怎么做?