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
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.
Most helpful comment
Ok, I am so sorry, i just foung the problem.
in filter_fields I didnt put the comma for making it a tuple.