Skip to main content

A Django app to easily manage custom url linked to static files.

Project description

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
  • PDF

How it works

There is possible to use this app in two ways:

  1. 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.
  2. 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

  1. Run pip install django-custom-url
  2. Add custom_url to settings.INSTALLED_APPS like this:
    INSTALLED_APPS = [
        ...
        'custom_url',
    ]
  1. Run python manage.py migrate

Setup

If you want to use the fallback view (option 1 of the "How it works" section):

  1. 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):

  1. Include the Custom URL URLconf in your project urls.py like this:
    from django.urls import include
    urlpatterns = [
        ...
        path('', include('custom_url.urls'))
    ]
  1. Create your custom URLs in the admin site.
  2. Run python .\manage.py update_urls to 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-custom-url-0.2.tar.gz (8.2 kB view details)

Uploaded Source

File details

Details for the file django-custom-url-0.2.tar.gz.

File metadata

  • Download URL: django-custom-url-0.2.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.0

File hashes

Hashes for django-custom-url-0.2.tar.gz
Algorithm Hash digest
SHA256 06837b0380f147bec631a4090f87b75665f434eea1c53104e5936609ab860986
MD5 22d7a84036e4e818c084a04a4b7c65ee
BLAKE2b-256 50898d0f335b74b9233ddd78b7a93ccdb2f492f74fbbdea61762aa2398cf0150

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page