Skip to main content

Django Remove Trailing Slash

A simple Django middleware that enforces a "no trailing slash" policy by permanently redirecting (301) any URL ending in a slash to its non-slashed version.

This is useful for SEO purposes to prevent duplicate content indexing.

Features

  • Performs a 301 Permanent Redirect.
  • Preserves query strings.
  • Ignores the root path (/).
  • Allows configurable exclusion of URL prefixes (e.g., /admin/, /api/).

Installation

pip install bear-django-remove-trailing-slash

Usage

  1. Add the middleware to your MIDDLEWARE list in settings.py. It is recommended to place it before Django's CommonMiddleware.
# settings.py
MIDDLEWARE = [
   'remove_slash.middleware.RemoveTrailingSlashMiddleware',
    # ... other middleware
]
  1. (Optional) By default, the middleware ignores URLs starting with /admin/. You can customize this by adding REMOVE_SLASH_IGNORE_PREFIXES to your settings.py.
# settings.py
REMOVE_SLASH_IGNORE_PREFIXES = ['/admin/', '/api/v1/']

That's it! The middleware will now automatically handle redirects.

Metadata

Release files for bear-django-remove-trailing-slash 0.1.0

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

Source distribution (sdist)

Source distribution for bear-django-remove-trailing-slash 0.1.0
File Size Uploaded Provenance Actions
bear_django_remove_trailing_slash-0.1.0.tar.gz 2.5 kB Without provenance Details for bear_django_remove_trailing_slash-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bear-django-remove-trailing-slash 0.1.0
File Interpreter ABI Platform Actions
bear_django_remove_trailing_slash-0.1.0-py3-none-any.whl Python 3 none any Details for bear_django_remove_trailing_slash-0.1.0-py3-none-any.whl

Total release size: 5.4 kB

Release files / bear_django_remove_trailing_slash-0.1.0.tar.gz

Download URL bear_django_remove_trailing_slash-0.1.0.tar.gz
Size 2.5 kB
Tags Source
SHA-256 checksum
How to use checksums
1d58c7b1183ac3203dcae68a22ab69bfeb59b9db23134a9fb9469115e73a2940
BLAKE2b-256 checksum
How to use checksums
5100fb912bbf323e58a454d756a652a62e43857c58a7fe4ee66fcda4c85da964
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.0

Release files / bear_django_remove_trailing_slash-0.1.0-py3-none-any.whl

Download URL bear_django_remove_trailing_slash-0.1.0-py3-none-any.whl
Size 2.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6a2ecf6a4a6d6da80a39995d61842d94f6835ec9c48ebb67fe86996cc4610cb8
BLAKE2b-256 checksum
How to use checksums
cbc83cba3c0b0b7ca8c3008404250fa7a276ed4abc06f32c46a6d5db06d2785d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.0

Security for bear-django-remove-trailing-slash 0.1.0

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 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