Django-filter: Meta.fields contains a field that isn't defined on this FilterSet

Created on 26 Nov 2015  ·  1Comment  ·  Source: carltongibson/django-filter

Hello,

I am having some error that I dont understand why is it happening.

I receive this error the error below while using django rest framework in a call to a model that has a ForeignKey.

Error:
Meta.fields contains a field that isn't defined on this FilterSet
From:
django_filters/filterset.py
Django version 1.8.5
django-filter version 0.11.0

My model is the following:

class Contract(models.Model):
    idContract = models.AutoField(db_column='idContract',primary_key=True)  
    idClient = models.ForeignKey(Client, db_column='idClient',related_name='+')
    contractmode = models.ForeignKey('Ccontractmode', db_column='ContractMode',related_name='+') 
    applicationdate = models.DateTimeField(db_column='applicationDate',null=True) 
    deliverydate = models.DateTimeField(db_column='deliveryDate', blank=True, null=True) 
    expirationdate = models.DateTimeField(db_column='expirationDate',null=True)
    mode = models.CharField(max_length=16)

    class Meta:
        managed = False
        db_table = 'Contract'
        default_permissions = ('add', 'change', 'delete', 'view')

I would appreciate a lot if you could tell me if this is a bug or I have something wrong.
Thanks a lot.
Adam

Most helpful comment

Ok, I am so sorry, i just foung the problem.

class ContractViewSet(viewsets.ModelViewSet):
    permission_classes = (DjangoModelPermissions2,
                          DjangoObjectPermissions2,)
    queryset = Contract.objects.all()
    serializer_class = ContractSerializer
    filter_backends = (filters.DjangoFilterBackend,)
    filter_fields = ('applicationdate',)

in filter_fields I didnt put the comma for making it a tuple.

>All comments

Ok, I am so sorry, i just foung the problem.

class ContractViewSet(viewsets.ModelViewSet):
    permission_classes = (DjangoModelPermissions2,
                          DjangoObjectPermissions2,)
    queryset = Contract.objects.all()
    serializer_class = ContractSerializer
    filter_backends = (filters.DjangoFilterBackend,)
    filter_fields = ('applicationdate',)

in filter_fields I didnt put the comma for making it a tuple.

Was this page helpful?
0 / 5 - 0 ratings