Coder Social home page Coder Social logo

django-conditional-views's Introduction

Django Conditional Views

Build Status Test Coverage Documentation Status

MIT License

Simple ETag and Last-Modified mixins for class based views.

What is Django Conditional Views?

Django Conditional Views builds off of the built in django conditional view processing machinery to provide simple mixins for class based views that implement support for the ETag and Last-Modified conditional request headers.

Features

Inherit one of these mixins to make your TemplateView's, DetailView's, or ListView's:

  1. Calculate and append ETag and/or Last-Modified headers to the response and;
  2. Respond with a 304 Not Modified or a 412 Precondition Failed to requests that provide conditional response headers such as If-Modified-Since
Helpful Defaults
  • ETags are automatically generated from the response.content.
  • ETag generation can be customized both before and after the response is rendered.
  • The Last Modified header is automatically set from the last modified timestamp of the template.
  • In the case of the DetailView and ListView mixins, the Last Modified header may also be configured to get the last modification timestamp from a field on the model, in which case the lastest of that or the template's last modified timestamp will be used.

Getting Started

First install django-conditional-views

$ pip install django-conditional-views

Then inherit from one of the following mixins in your views:

  • ConditionalGetMixin - Inherits from View
  • ConditionalGetTemplateViewMixin - Inherits from TemplateView
  • ConditionalGetListViewMixin - Inherits from ListView
  • ConditionalGetDetailViewMixin - Inherits from DetailView

See the Usage and API sections of the documentation for more details.

Contributing

Contributions are welcome.

Getting Started

To work on the Pendulum codebase, you'll want to clone the project locally and install the required dependencies via poetry.

$ git clone [email protected]:cordery/django-conditional-views.git
$ poetry develop

Running Tests

django-conditional-views uses pytest. To run tests:

$ pytest

django-conditional-views's People

Contributors

cordery avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.