Skip to main content

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 git@github.com:cordery/django-conditional-views.git
$ poetry develop

Running Tests

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

$ pytest

Release files for django-conditional-views 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-conditional-views 0.1.3
File Size Uploaded
django_conditional_views-0.1.3.tar.gz 8.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-conditional-views 0.1.3
File Interpreter ABI Platform
django_conditional_views-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 29.7 kB

Release files / django_conditional_views-0.1.3.tar.gz

Download URL django_conditional_views-0.1.3.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
bff03fc06ab859a739ce81904d28d3d4355dcdb0420b21c9598212e469775fa4
BLAKE2b-256 checksum
How to use checksums
c91b3963850d1f47eb2812189eb7341c88455f59295956edc75b1fdd394d5623
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.11.5 CPython/2.7.15 Darwin/17.7.0

Release files / django_conditional_views-0.1.3-py3-none-any.whl

Download URL django_conditional_views-0.1.3-py3-none-any.whl
Size 21.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
296d4a98446d98c48cd2c64e4378ee2584575441180a711c334f7ff908a6f5ed
BLAKE2b-256 checksum
How to use checksums
690c3d8a870095145aaa42128b78ab2641314fae23a1b84f19e1a02cfb451958
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.11.5 CPython/2.7.15 Darwin/17.7.0

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page