From 9452242595cebc02b3a3dcbeb07f36e68ff1ef74 Mon Sep 17 00:00:00 2001 From: Trevor Cox Date: Mon, 7 Nov 2016 19:46:13 -0500 Subject: [PATCH] Update urls.py, url template tag for Django 1.8. Bookmarklet: don't assume shortener app is at URL root (e.g. support /shortener/). --- shortener/urls.py | 6 +++++- templates/base.html | 4 ++-- templates/shortener/form.inc.html | 2 +- templates/shortener/index.html | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/shortener/urls.py b/shortener/urls.py index 19c3abe..390eeb7 100644 --- a/shortener/urls.py +++ b/shortener/urls.py @@ -1,4 +1,8 @@ -from django.conf.urls.defaults import patterns, url +try: + from django.conf.urls import patterns, url +except: + # Django <=1.5 + from django.conf.urls.defaults import patterns, url urlpatterns = patterns('shortener.views', diff --git a/templates/base.html b/templates/base.html index 20cdfb6..480256d 100644 --- a/templates/base.html +++ b/templates/base.html @@ -5,7 +5,7 @@ -

{{ request.META.HTTP_HOST }}

+

{{ request.META.HTTP_HOST }}


{% block content %}{% endblock %} @@ -15,7 +15,7 @@

{{ request.META.HTTP_HOST }}

{% block bookmarklet %}
Bookmarklet (drag this to your bookmarks bar):
- Shorten with {{ request.META.HTTP_HOST }} + Shorten with {{ request.META.HTTP_HOST }} {% endblock %} {% block extra_body %}{% endblock %} diff --git a/templates/shortener/form.inc.html b/templates/shortener/form.inc.html index 959dda9..a19b1f9 100644 --- a/templates/shortener/form.inc.html +++ b/templates/shortener/form.inc.html @@ -1,5 +1,5 @@ {% if link_form %} -
+ {% csrf_token %} {{ link_form.as_p }} diff --git a/templates/shortener/index.html b/templates/shortener/index.html index ac37b42..766e5c3 100644 --- a/templates/shortener/index.html +++ b/templates/shortener/index.html @@ -6,7 +6,7 @@

Recent Links

@@ -14,7 +14,7 @@

Most Popular Links

{% endblock content %}