Django middleware that makes urls ending with and without slashes equivelent
Project description
# drf-ignore-slash-middleware
Django middleware that makes urls ending with and without slashes equivalent
When using [DRF](https://www.django-rest-framework.org) routers you have a choice to either have urls end with trailing slash (default) or not.
i.e `DefaultRouter(trailing_slash=False)`. You can't however have it both ways, as in ignore them.
This package defines a very simple middleware class that removes trailing slashes from urls if they have one.
So in order to ignore trailing slashes and have `/api/some_url` be equivalent to `/api/some_url/` simply install the package and add the middleware class as the first entry in the MIDDLEWARE list. Please note that middleware [changed in django 1.10](https://docs.djangoproject.com/en/1.10/topics/http/middleware/) and this this pacakge requires django version >= 1.10.
```python
MIDDLEWARE = [
# Should be first entry
'drf_ignore_slash_middleware.SlashIgnoreMiddleware',
# Rest of your middleware
]
```
Django middleware that makes urls ending with and without slashes equivalent
When using [DRF](https://www.django-rest-framework.org) routers you have a choice to either have urls end with trailing slash (default) or not.
i.e `DefaultRouter(trailing_slash=False)`. You can't however have it both ways, as in ignore them.
This package defines a very simple middleware class that removes trailing slashes from urls if they have one.
So in order to ignore trailing slashes and have `/api/some_url` be equivalent to `/api/some_url/` simply install the package and add the middleware class as the first entry in the MIDDLEWARE list. Please note that middleware [changed in django 1.10](https://docs.djangoproject.com/en/1.10/topics/http/middleware/) and this this pacakge requires django version >= 1.10.
```python
MIDDLEWARE = [
# Should be first entry
'drf_ignore_slash_middleware.SlashIgnoreMiddleware',
# Rest of your middleware
]
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file drf_ignore_slash_middleware-0.0.1.tar.gz.
File metadata
- Download URL: drf_ignore_slash_middleware-0.0.1.tar.gz
- Upload date:
- Size: 1.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ed51accc471b44c8e7986e3667669f74e7fa303a516f774d7931d069c1d6f0d
|
|
| MD5 |
11275ee9577c9a6d73d25d26a86f0b50
|
|
| BLAKE2b-256 |
a10800ecbea7817303fde854a44e8455a64f138aaceb4de811c3464dcec91ba8
|
File details
Details for the file drf_ignore_slash_middleware-0.0.1-py3-none-any.whl.
File metadata
- Download URL: drf_ignore_slash_middleware-0.0.1-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c17b6c2ce16685455df4be0fe7d34c5f6fa4c61ddb4660ca5f253ea08914469
|
|
| MD5 |
88cef76ca428e55ff349464eeb73cf53
|
|
| BLAKE2b-256 |
403da019e71fe3cf296efe06a7fd0c3e0de222624e55e305f4b15028f618b93d
|