-
Notifications
You must be signed in to change notification settings - Fork 82
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
AttributeError: module 'rest_framework.filters' has no attribute 'FilterSet' #3
Comments
Same - the reason is that FilterSet is part of
|
@deepesh-packt did a PR fix this? If not, this is still going to cause problems for people following along with the text |
I kept playing until I got the correct references from here: The correct import in Views.py is like this:
and the code for
|
It worked for me! I was using "name" instead of "field_name" which caused the problem. |
I was having success adapting the contents of the book up to chapter 7, for django 4.1.5 and Python 3.10.6 when I ran into this same problem. I made the adjustments suggested here until my comment, but I see that the CompetitionFilter class is not having an effect, I tried to access the URL: http://localhost:8000/drones/competitions/?pilot_name=Penelope+Pitstop&drone_name=WonderDrone and all competitions are returned. my code is available at: https://github.com/carlosdelfino/Django-RESTful-Web-Services |
I found the solution to the problem, follow the path performed: |
If you've forked the repo and updated the code to work, remember to file a PR so that the official repository can be updated, instead of telling people to use your repository. |
Please, also remember to rename "filter_fields" to "filterset_fields" in the classes with the List suffix (DroneCategoryList, DroneList, and PilotList), else request with filter query parameter will always return list of all the objects. |
from django_filters import FilterSet, AllValuesFilter, DateTimeFilter, NumberFilter |
I was practicing Chapter08.
When I run the program Times the following error, please help fix it, thank you.
AttributeError: module restore _ framework.filters' has no attribute extension FilterSet'
Relevant information:
Djaog 1.11.11.
Python 3.6.
Djangorestframework-3.6.4
The text was updated successfully, but these errors were encountered: