django-custom-url
django-custom-url is a Django app to easily manage custom url linked to static files.
Django is a great framework, but if you want to create URLs linked to static files, you have to create a view for that purpose. And if you have to manage not just one but severals of these URLs, you'll end up with a bunch of dummy views.
This app allows you to create a custom URL and upload a file linked to that URL, so that when a user requests the URL, they can view or download the related file (depending on whether it is a valid format for viewing from the browser).
Supported file types
- Plain Text
- CSV
- MS Excel
- MS Word
- MS PowerPoint
- GIF
- JPEG
- PNG
- TIFF
- SVG
How it works
There is possible to use this app in two ways:
- Use a fallback view that will check for a custom URL if all other URL patterns fails. This options doesn't require restarting your application server, just adding the custom URLs in the admin site, and it will work.
- Execute an administrative command after creating the custom URLs in the admin, which will harcode URLs in a urls.py file. This option require restarting you application server each time a URL is added or modified.
Installation
- Run
pip install django-custom-url - Add
custom_urltosettings.INSTALLED_APPSlike this:
INSTALLED_APPS = [
...
'custom_url',
]
- Run
python manage.py migrate
Setup
If you want to use the fallback view (option 1 of the "How it works" section):
- Include the Custom URL view in your project urls.py. Include it at the end of the path list like this:
from custom_url.views import CustomUrlView
urlpatterns = [
...
path('<path:url>', CustomUrlView.as_view())
]
If you want to opt for the hardcoded URLs (option 2 of the "How it works" section):
- Include the Custom URL URLconf in your project urls.py like this:
from django.urls import include
urlpatterns = [
...
path('', include('custom_url.urls'))
]
- Create your custom URLs in the admin site.
- Run
python .\manage.py update_urlsto update the Custom URL urls.py file.
License
Released under MIT License.
Support
If you are having issues, please let me know through raising an issue, or just sending me a DM to @luciano_dev.
Metadata
Release files for django-custom-url 0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django-custom-url-0.3.tar.gz | 13.5 kB | Details |
Release files / django-custom-url-0.3.tar.gz
| Download URL | django-custom-url-0.3.tar.gz |
|---|---|
| Size | 13.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f5121c2365c171758965766804c88ab13e71ad2ed690ebab4be853c9c6d20066
|
|
BLAKE2b-256 checksum How to use checksums |
a20513538026eb5305b2e515c5526a66a0e368db1028c82e74a8c76236a2f37f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.9.13
|