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

Restframework2 filter #353

Merged
merged 16 commits into from Nov 9, 2012
Merged

Restframework2 filter #353

merged 16 commits into from Nov 9, 2012

Conversation

benkonrath
Copy link
Contributor

Pull request #290 against master. I still need to:

  1. Write the docs.
  2. Factor things into a PageField.get_page_url(self, page) as per this comment:

#290 (comment)

This reverts commit 5b399a8.

This has been reverted because it's not working properly.
@tomchristie
Copy link
Member

Looking good.

@jacobsvante
Copy link
Contributor

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)
Copy link
Member

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.

@tomchristie
Copy link
Member

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
Copy link
Contributor

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

@tomchristie
Copy link
Member

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.

@tomchristie tomchristie merged commit 09f39bd into encode:master Nov 9, 2012
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 09f39bd on onepercentclub:restframework2-filter into * on tomchristie:master*.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants