我对 django 和 sweetpie 有疑问
给出以下代码:
class CandidatePollResource(ModelResource):
class Meta:
queryset = Candidate.objects.all()
resource_name = "candidate-poll"
filtering = {"status": ALL }
class Candidate(Profile):
"""
This profile stores all information about a candidate.
"""
status = models.CharField(_('status'), max_length=15, blank=True, choices=CANDIDATE_STATUS_CHOICES)
class Profile(models.Model):
"""
Abstract basic class all profiles should inherit.
"""
user = models.OneToOneField(CustomUser,related_name='%(class)s',)
invitationdate = models.DateField(_('invitationdate'), null=True, blank=True)
confirmationdate = models.DateField(_('confirmationdate'), null=True, blank=True)
activation_key = models.CharField(_('activation_key'), max_length=32, blank=True)
# Adding of "class" here is important for this to work. See
# http://thedjangoforum.com/board/thread/417/reverse-query-name-for-field-clash/?page=1
created_by = models.ForeignKey(CustomUser, related_name='%(class)s_created', blank=True, null=True)
objects = ProfileManager()
class Meta:
abstract = True
每次我们尝试调用过滤结果集(http://localhost:3000/api/v1/candidate-poll/?status__exact=new
)时,我总是收到以下错误
The 'status' field does not allow filtering.
如何在该字段上启用过滤?