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
Restframework2 filter #353
Restframework2 filter #353
Conversation
The filter support uses django-filter to work its magic.
This changes the test from the failing checking for status 400. See discussion here: #169 (comment)
This fixes a Travis build failures on python 2.6: https://travis-ci.org/#!/tomchristie/django-rest-framework/builds/2746628
This git revision has the django 1.3 compatibility pull request.
This reverts commit 5b399a8. This has been reverted because it's not working properly.
Looking good. |
What about merging in the code and creating a separate pull request for documentation? IMHO this is the one big feature missing from DRF. |
|
||
if filter_class: | ||
assert issubclass(filter_class.Meta.model, self.model), \ | ||
"%s is not a subclass of %s" % (filter_class.Meta.model, self.model) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't bother with this assert. More pythonic to not strictly enforce the type.
Wrote some initial docs yesterday evening (not pushed yet) https://gist.github.com/4030676 Note that the django-filter backend (and any others) will be pluggable, not hardwired. Will need some minor changes in the pull req (although I can take them on if needed) |
if request: | ||
for field, value in request.QUERY_PARAMS.iteritems(): | ||
if field != self.page_field: | ||
relative_url += '&%s=%s' % (field, value) | ||
return request.build_absolute_uri(relative_url) | ||
return relative_url |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use urllib.urlencode:
params = {self.page_field: page}
if request:
params.update([(field, value) for (field, value) in d.iteritems() if field != self.page_field])
relative_url = '?' + urllib.urlencode(params)
if request:
return request.build_absolute_uri(relative_url)
return relative_url
Made some updates, mainly making sure that filtering backends are pluggable (like other REST framework components), and that django-filter is optional. Pull req is: #383 Needs some last few updates to documentation and we're done. |
Changes Unknown when pulling 09f39bd on onepercentclub:restframework2-filter into * on tomchristie:master*. |
Pull request #290 against master. I still need to:
#290 (comment)