Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

django.core.exceptions.FieldError: Related Field got invalid lookup: id #8

Open
peppelinux opened this issue Mar 14, 2017 · 0 comments

Comments

@peppelinux
Copy link

peppelinux commented Mar 14, 2017

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant