Skip to main content

Django Web Utils

Some helpers for working with the web.

Provided are:

format_currency

formats currency (USD) to a string.

>>> cash = 1250
>>> formatted = format_currency(cash)
'$1,250.00'
>>> formatted = format_currency(cash, places=0)
'$1,250'
>>> cash = 0
>>> formatted = format_currency(cash, show_zero=False)
''

format_currency template tag

For django to be able to find the templatetags, you’ll need to register web_utils in your INSTALLED_APPS settings

{% load formatting_tags %}

# value, places, show_zero flag. {% format_currency cash_amount 0 “False” %}

ping_google_sitemap

A signal receiver to ping Google Sitemap to let them know your content changed

  1. Add the following to settings.py PING_GOOGLE_SITEMAP = True SITE_DOMAIN = ‘http://www.example.com

  2. Add a named url: ‘sitemap’ so the method can resolve your sitemap url

  3. Register the receiver on whatever signal you’d like to trigger the ping.

    receiver(models.signals.post_save, sender=BlogEntry, dispatch_uid=”BlogEntry”)(ping_google_sitemap)

SSLMiddleware

Allows you to force various urls through https or http

  1. Add SSL_ENABLED = True to your settings.py

  2. Add web_utils.middleware.SSLMiddleware to your middleware settings

  3. Add a USE_SSL = True/False to a route’s view_kwargs

    url(r’^admin/’, include(admin.site.urls), kwargs={‘USE_SSL’: True}),

By default, all routes will be forced to http unless they have USE_SSL=True If you would like to flip this and secure everything except only specific routes add USE_SSL_DEFAULT=True to your settings.

Download files

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

Source Distribution

django-web-utils-0.4.4.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

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

django_web_utils-0.4.4-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file django-web-utils-0.4.4.tar.gz.

File metadata

  • Download URL: django-web-utils-0.4.4.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for django-web-utils-0.4.4.tar.gz
Algorithm Hash digest
SHA256 4ec75bd4b220ce2b3e4f46553b03ff67da45be4c2714c60f811fd3d4ad35b7dc
MD5 ceda8c1653154186e9adcc1a1502db12
BLAKE2b-256 df10f1f2039eee86a6fcece2f95b30d110a4ae151b46dcadc5edc18fc0779539

See more details on using hashes here.

File details

Details for the file django_web_utils-0.4.4-py3-none-any.whl.

File metadata

  • Download URL: django_web_utils-0.4.4-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for django_web_utils-0.4.4-py3-none-any.whl
Algorithm Hash digest
SHA256 bf186418d1e77fe36e313340ec53da9b71bee8a097f6c881d331e4333c06db0f
MD5 c8723753d31285522d0922c723e6c8f4
BLAKE2b-256 d2178d6f5114554eed044ed427a7f139f2ae0ab80338aee345b163142da498f1

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 Sentry Error logging StatusPage Status page