Code Monkey home page Code Monkey logo

django-template-urls's Introduction

This is a very simple library to help with URLs in Django templates. Basically, this is a set of two template filters,
which ensure that any URLs they are given are either absolute or relative. This is very useful if you have a lot of
get_url methods and the such defined which return relative URLs and you want them displayed on the site as absolute
ones (or vice-versa, although that's less common for sure).

To use this, you'll need to copy the templatetags directory into one of your applications. If you're not familiar with
doing this, you'll find more information at http://docs.djangoproject.com/en/dev/howto/custom-template-tags/

Now you should be good to go. Put a {% load urls %} at the top of any of your templates you want to use the library in,
and then you can do things like {{ variable|absolute_url }} or {{ variable|relative_url }}.

To note is that the domain is taken from the Django sites application (Site.objects.get_current().domain) -- so if
you're not using sites, this won't work. If you are, make sure that it's up-to-date :)

django-template-urls's People

Contributors

obeattie avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  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.