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.

Release files for django-web-utils 0.4.6

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-web-utils 0.4.6
File Size Uploaded
django-web-utils-0.4.6.tar.gz 11.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-web-utils 0.4.6
File Interpreter ABI Platform
django_web_utils-0.4.6-py3-none-any.whl Python 3 none any Details

Total release size: 27.8 kB

Release files / django-web-utils-0.4.6.tar.gz

Download URL django-web-utils-0.4.6.tar.gz
Size 11.5 kB
Tags Source
SHA-256 checksum
How to use checksums
dd550d7baac1f87139da3eeef5d7dde742cbc6be43cc8035845a82ea9175d2f4
BLAKE2b-256 checksum
How to use checksums
cedb00c44a37380025747858a592157f77b0399a51a89b8f0b5d5d9222fd7ec8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release files / django_web_utils-0.4.6-py3-none-any.whl

Download URL django_web_utils-0.4.6-py3-none-any.whl
Size 16.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5384baeb3e5e40a60544ffa6e821ebbc3a8e57f9b4a7f15ae500382f18e17511
BLAKE2b-256 checksum
How to use checksums
1d82cd17a8d1ee819b5188f7ad6eeefcc60a2f054bf814b897714aebfbbe47a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release history Release notifications | RSS feed

This release

0.4.6 This release

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

1 release file

0.4.2

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.2

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

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