Skip to main content

Seo ville slugger will solve the problems you are having with django, media files and filenames.

Django’s default storage backend has some pretty annoying behaviour. When uploading the same file for the second time, you get a second file on disk with some kind of crazy hash value added at the end.

There are 2 kinds of people that are not happy with that.

  1. The person that has to pay for disk space

  2. The SEO people your customer has hired.

This storage backend stores files named after their hash value and adds a symlink with the original name. No duplication and you can SEO your heart out.

Media file and pagespeed mobile score

Ideally, you would want to have long cache expiry headers for your site’s uploaded files, Just like you’ve got with your static files. That usually poses a problem in conjunction with the pretty urls. It is safe to put long expiry headers when using SEOStorage, because the files are distributed over folders named after a tiny piece of the hash. Obviously this small hash could lead to collisions, so the storage backend will prevent it as follows:

In the rare case we encounter two different files with exactly the same filename, and they end up in the same folder due to hash collision, the new file will not get the pretty SEO url. Instead the full hashed filename will be used instead. In these rare cases you might get a SEO unfriendly url.

We can’t worry about that can we? Phat phat chance anyone will notice!

Usage

You can use the storage backend on a global level by adding the following to your django settings:

DEFAULT_FILE_STORAGE = 'seo.ville.slugger.SEOStorage'

Sorl thumbnail

Suppose you want sorl thumbnail to also have nice urls based on the original filename?:

THUMBNAIL_BACKEND = 'seo.ville.sorl.SEOThumbnailBackend'
THUMBNAIL_STORAGE  = 'seo.ville.sorl.SEOThumbnailStorage'

With sorl you can pass the slug as a parameter to the thumbnail tag:

{% thumbnail image "330x450" upscale=True slug=slug as thumb %}

Settings

HASH_BLOCKSIZE change this if you think hashing of the file use too much or not enough memory HASH_DIRNAME_SLICE_SIZE change this if you find there are too many collisions.

Metadata

Release files for seo-ville-slugger 0.0.7

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

Source distribution (sdist)

Source distribution for seo-ville-slugger 0.0.7
File Size Uploaded Provenance
seo-ville-slugger-0.0.7.tar.gz 4.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for seo-ville-slugger 0.0.7
File Interpreter ABI Platform
seo_ville_slugger-0.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 23.1 kB

Release files / seo-ville-slugger-0.0.7.tar.gz

Download URL seo-ville-slugger-0.0.7.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
ac2f02efb3bac6a42a3e84b016751d97ea9c4845f152dbc3b0435ea158d2c667
BLAKE2b-256 checksum
How to use checksums
33e19761ac78659117fb7aea582a7599fe2390d7529e22645ee3403083028a45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/3.6

Release files / seo_ville_slugger-0.0.7-py3-none-any.whl

Download URL seo_ville_slugger-0.0.7-py3-none-any.whl
Size 18.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
59532a009c60fc26dc0ce630ca7758eb42a19d5589da126c6d0754ee5a99cd51
BLAKE2b-256 checksum
How to use checksums
b60c125f0d48d7aad13f569363d4a9aa6ef9e9b5e3466115b40c3926b346f3b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/3.6

Security for seo-ville-slugger 0.0.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.0.7 This release

2 release files No provenance

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