Skip to main content

Django tools from WITH

Project description

Django Wools

Django tools from WITH.

That's a collection of things that we at WITH got tired of copy/pasting in every project.

Install

pip install django_wools

Included Wools

Storage

django_wools.storage.GzipManifestStaticFilesStorage

That's a sub-class of the ManifestStaticFilesStorage but that makes sure that along with all the files comes a .gz version which is easy to pick up for nginx (or other static files server).

Middlewares

django_wools.middlewares.NowMiddleware

Suppose that you have a content that is available up until a given date. When the date is passed then everything related to this content expires. However, in order to do this, you're probably going to make several request, possibly in loosely connected parts of your code. In those cases, when looking at the time, the clock will show different value as the time passes between calls. It means that you could very well end up with one half of your code considering that the object is still valid but the other half that it expired.

In order to prevent this, the simplest is to consider that the time is fixed and that the code executes instantly at the moment of the request. The goal of this middleware is to save the current time at each request and then to provide an easy way to get the current time through the request.

If the middleware is activated, you should be able to get the time like this:

from time import sleep
from django.shortcuts import render

def my_view(request):
    print(f"Now is {request.now()}")
    sleep(42)
    print(f"Now is still {request.now()}")

    return render(request, "something.html", {"now": request.now()})

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_wools-0.1.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_wools-0.1.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file django_wools-0.1.0.tar.gz.

File metadata

  • Download URL: django_wools-0.1.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.8.2 Linux/4.19.0-8-amd64

File hashes

Hashes for django_wools-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1bcbb1f3b5a72c069614405515aaa15bd7dbbf66355c48eda86db5fa85eb51cc
MD5 726ddd2fcf98ac760b7dcd5810343937
BLAKE2b-256 59239929b637220d18361add4805ec371c9b1487471309a30ebc12ebcb29af30

See more details on using hashes here.

File details

Details for the file django_wools-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: django_wools-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.8.2 Linux/4.19.0-8-amd64

File hashes

Hashes for django_wools-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2dca90e6750b746813bfa15bddbd92f25d51a59939c76a13ddf36a473d2b0cc9
MD5 1035cae9bccebecc02583a66f5c53e74
BLAKE2b-256 0c2060dfba90b4cba21dd892ef62e4dd7ea301dabc0585b73298cd2c97df7b8a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page