django.core.exceptions.FieldError: Related Field got invalid lookup: id
peppelinux opened this issue · comments
If in a model is used another primary_key label, different from the classical id name, it should be better use %s__pk__exact instead of %s__id__exact.
I made this change in my fork but I also cleaned the demo-app and the most of dependencies in requirements, so I cannot do a pull request. Just this, in
dal_admin_filters/__init__.py
def queryset(self, request, queryset):
if self.value():
lookup = "%s__id__exact" % self.parameter_name
return queryset.filter(**{lookup: self.value()})
else:
return queryset
became:
def queryset(self, request, queryset):
if self.value():
lookup = "%s__pk__exact" % self.parameter_name
return queryset.filter(**{lookup: self.value()})
else:
return queryset