All Projects → miki725 → Django Url Filter

miki725 / Django Url Filter

Licence: other
Django URL Filter provides a safe way to filter data via human-friendly URLs.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Django Url Filter

Django Hashid Field
Django Model Field that uses Hashids to obscure the value
Stars: ✭ 256 (-1.16%)
Mutual labels:  django, django-rest-framework
Django Rest Passwordreset
An extension of django rest framework, providing a configurable password reset strategy
Stars: ✭ 238 (-8.11%)
Mutual labels:  django, django-rest-framework
Ownphotos
Self hosted alternative to Google Photos
Stars: ✭ 2,587 (+898.84%)
Mutual labels:  django, django-rest-framework
Drf Access Policy
Declarative access policies/permissions modeled after AWS' IAM policies.
Stars: ✭ 200 (-22.78%)
Mutual labels:  django, django-rest-framework
Django Rest Registration
User-related REST API based on the awesome Django REST Framework
Stars: ✭ 240 (-7.34%)
Mutual labels:  django, django-rest-framework
Blogbackendproject
Backend code for my blogs, develop with Django Rest framework.
Stars: ✭ 204 (-21.24%)
Mutual labels:  django, django-rest-framework
Rest Api
Learn how to build your own REST API with Python, Django, and the Django Rest Framework.
Stars: ✭ 232 (-10.42%)
Mutual labels:  django, django-rest-framework
Djangorestframework Stubs
PEP-484 stubs for django-rest-framework
Stars: ✭ 191 (-26.25%)
Mutual labels:  django, django-rest-framework
Fosswebsite
A club management system that handles student details, progress, events, achievements, attendance, status updates, teams and workshop registrations. This is the official [email protected] website
Stars: ✭ 242 (-6.56%)
Mutual labels:  django, django-rest-framework
Django Rest Framework Datatables
Seamless integration between Django REST framework and Datatables.
Stars: ✭ 241 (-6.95%)
Mutual labels:  django, django-rest-framework
Vecihi
Build Your Own Photo Sharing App in 5 minutes
Stars: ✭ 199 (-23.17%)
Mutual labels:  django, django-rest-framework
Django Practice Book
《Django企业开发实战》已出版
Stars: ✭ 251 (-3.09%)
Mutual labels:  django, django-rest-framework
Django Rest Auth
This app makes it extremely easy to build Django powered SPA's (Single Page App) or Mobile apps exposing all registration and authentication related functionality as CBV's (Class Base View) and REST (JSON)
Stars: ✭ 2,289 (+783.78%)
Mutual labels:  django, django-rest-framework
Treeherder
A system for managing CI data for Mozilla projects
Stars: ✭ 212 (-18.15%)
Mutual labels:  django, django-rest-framework
Rengorum
🚀 Forum app built in React, Redux & Django
Stars: ✭ 194 (-25.1%)
Mutual labels:  django, django-rest-framework
Djangochannelsrestframework
A Rest-framework for websockets using Django channels-v3
Stars: ✭ 224 (-13.51%)
Mutual labels:  django, django-rest-framework
Django Enumfield
Custom Django field for using enumerations of named constants
Stars: ✭ 184 (-28.96%)
Mutual labels:  django, django-rest-framework
Drf Yasg
Automated generation of real Swagger/OpenAPI 2.0 schemas from Django REST Framework code.
Stars: ✭ 2,523 (+874.13%)
Mutual labels:  django, django-rest-framework
Tacticalrmm
A remote monitoring & management tool, built with Django, Vue and Go.
Stars: ✭ 231 (-10.81%)
Mutual labels:  django, django-rest-framework
Tweetme 2
Build a twitter-like app in Django, Bootstrap, Javascript, & React.js. Step-by-Step.
Stars: ✭ 247 (-4.63%)
Mutual labels:  django, django-rest-framework

================= Django URL Filter

.. image:: https://badge.fury.io/py/django-url-filter.svg :target: http://badge.fury.io/py/django-url-filter .. image:: https://readthedocs.org/projects/django-url-filter/badge/?version=latest :target: http://django-url-filter.readthedocs.io/en/latest/?badge=latest .. image:: https://drone.miki725.com/api/badges/miki725/django-url-filter/status.svg :target: https://drone.miki725.com/miki725/django-url-filter .. image:: https://codecov.io/gh/miki725/django-url-filter/branch/master/graph/badge.svg :target: https://codecov.io/gh/miki725/django-url-filter

Django URL Filter provides a safe way to filter data via human-friendly URLs.

Overview

The main goal of Django URL Filter is to provide an easy URL interface for filtering data. It allows the user to safely filter by model attributes and also allows to specify the lookup type for each filter (very much like Django's filtering system in ORM).

For example the following will retrieve all items where the id is 5 and title contains "foo"::

example.com/listview/?id=5&title__contains=foo

In addition to basic lookup types, Django URL Filter allows to use more sophisticated lookups such as in or year. For example::

example.com/listview/?id__in=1,2,3&created__year=2013

Requirements

  • Python 2.7, 3.x, pypy or pypy3
  • Django 1.8+ (there are plans to support older Django versions)
  • Django REST Framework 2 or 3 (only if you want to use DRF integration)

Installing

Easiest way to install this library is by using pip::

$ pip install django-url-filter

Usage Example

To make example short, it demonstrates Django URL Filter integration with Django REST Framework but it can be used without DRF (see below).

::

from url_filter.integrations.drf import DjangoFilterBackend

class UserViewSet(ModelViewSet): queryset = User.objects.all() serializer_class = UserSerializer filter_backends = [DjangoFilterBackend] filter_fields = ['username', 'email']

Alternatively filterset can be manually created and used directly to filter querysets::

from django.http import QueryDict from url_filter.filtersets import ModelFilterSet

class UserFilterSet(ModelFilterSet): class Meta(object): model = User

query = QueryDict('email__contains=gmail&joined__gt=2015-01-01') fs = UserFilterSet(data=query, queryset=User.objects.all()) filtered_users = fs.filter()

Above will automatically allow the use of all of the Django URL Filter features. Some possibilities::

# get user with id 5
example.com/users/?id=5

# get user with id either 5, 10 or 15
example.com/users/?id__in=5,10,15

# get user with id between 5 and 10
example.com/users/?id__range=5,10

# get user with username "foo"
example.com/users/?username=foo

# get user with username containing case insensitive "foo"
example.com/users/?username__icontains=foo

# get user where username does NOT contain "foo"
example.com/users/?username__icontains!=foo

# get user who joined in 2015 as per user profile
example.com/users/?profile__joined__year=2015

# get user who joined in between 2010 and 2015 as per user profile
example.com/users/?profile__joined__range=2010-01-01,2015-12-31

# get user who joined in after 2010 as per user profile
example.com/users/?profile__joined__gt=2010-01-01

Features

  • Human-friendly URLs

    Filter querystring format looks very similar to syntax for filtering in Django ORM. Even negated filters are supported! Some examples::

    example.com/users/?email__contains=gmail&joined__gt=2015-01-01 example.com/users/?email__contains!=gmail # note !

  • Related models

    Support related fields so that filtering can be applied to related models. For example::

    example.com/users/?profile__nickname=foo

  • Decoupled filtering

    How URLs are parsed and how data is filtered is decoupled. This allows the actual filtering logic to be decoupled from Django hence filtering is possible not only with Django ORM QuerySet but any set of data can be filtered (e.g. SQLAlchemy query objects) assuming corresponding filtering backend is implemented.

  • Usage-agnostic

    This library decouples filtering from any particular usage-pattern. It implements all the basic building blocks for creating filtersets but it does not assume how they will be used. To make the library easy to use, it ships with some integrations with common usage patterns like integration with Django REST Framework. This means that its easy to use in custom applications with custom requirements (which is probably most of the time!)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].