Giter VIP home page Giter VIP logo

django-paginator-rawqueryset's Introduction

django-paginator-rawqueryset

A django paginator for RawQuerySet. This allows you to pass a RawQuerySet into a custom paginator, resulting in more efficient pagination. Supports mysql, sqlite, and postgresql. Oracle 12.1 and Firebird support needs testing.

Installation

Installing the dev version:

pip install git+git://github.com/seamusmb/django-paginator-rawqueryset.git

Add 'rawpaginator' to your INSTALLED_APPS in settings.py

Usage

if you want a Paginator that can work with querysets, lists, and rawquerysets, do this:

   from rawpaginator.paginator import Paginator
   raw_qs = some_model.objects.raw("""SELECT * FROM some_model""")
   p = Paginator(raw_qs, 50)
   p.page(1)

or if you just want the RawQuerySetPaginator, you can do this:

   from rawpaginator.paginator import RawQuerySetPaginator
   raw_qs = some_model.objects.raw("""SELECT * FROM some_model""")
   p = RawQuerySetPaginator(raw_qs, 50)
   p.page(1)

In my tests, I'm getting up to 50% performance gains using this, mainly when paginating a large complex query. Don't bother using this for simple queries with a few pages, stick to the default paginator and cast the RawQuerySet to a list.

Tested with Django 2 and Python 3

django-paginator-rawqueryset's People

Contributors

askaliuk avatar mattbuck85 avatar nickcatal avatar ruxkor avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.