Git Product home page Git Product logo

django-custom-url's Introduction

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.

django-custom-url's People

Contributors

luciano-im avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.