Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

License

NotificationsYou must be signed in to change notification settings

cordery/django-conditional-views

Repository files navigation

Build StatusTest CoverageDocumentation 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 indjango conditional view processing machineryto provide simple mixins for class based views that implement support for the ETag and Last-Modifiedconditional 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 a304 Not Modified or a412 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 beconfigured to get the last modification timestamp from a field on the model, in which casethe 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 theUsage andAPI sections of thedocumentation for more details.

Contributing

Contributions are welcome.

Getting Started

To work on the Pendulum codebase, you'll want to clone the project locallyand install the required dependencies viapoetry.

$ git clone git@github.com:cordery/django-conditional-views.git$ poetry develop

Running Tests

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

$ pytest

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp