Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Remove hardcoded version numbers from the download page.

  • Loading branch information...
1 parent b1dbfa6 commit 1a94cedae7c9eacf5f755ec1bd37f9c3544576ca @aaugustin aaugustin committed
6 releases/
@@ -1,10 +1,10 @@
from __future__ import absolute_import, unicode_literals
-from django.conf.urls import patterns
+from django.conf.urls import patterns, url
from .views import index, redirect
urlpatterns = patterns('',
- (r'^$', index),
- (r'^([0-9a-z_.-]+)/(tarball|checksum|egg)/$', redirect),
+ url(r'^$', index, name='download'),
+ url(r'^([0-9a-z_.-]+)/(tarball|checksum|egg)/$', redirect, name='download-redirect'),
14 releases/
@@ -7,7 +7,19 @@
def index(request):
- return render(request, 'releases/download.html')
+ # Build a dictionary of x => latest 1.x.y release
+ releases = {}
+ for release in Release.objects.filter(status='f', major=1).order_by('minor', 'micro'):
+ releases[release.minor] = release
+ releases = [releases[minor] for minor in sorted(releases)]
+ current = releases.pop()
+ previous = releases.pop()
+ context = {
+ 'current_version': current.version,
+ 'previous_version': previous.version,
+ 'earlier_versions': [release.version for release in reversed(releases)],
+ }
+ return render(request, 'releases/download.html', context)
def redirect(request, version, kind):
21 templates/releases/download.html
@@ -13,17 +13,17 @@
<h2>Option 1. Get the latest official version</h2>
-<p>The latest official version is 1.5. You can get it by direct download:
+<p>The latest official version is {{ current_version }}. You can get it by direct download:
-<p>First, download <a href="">Django-1.5.tar.gz</a> (<a href="">checksums</a>). Then:</p>
+<p>First, download <a href="{% url 'download-redirect' current_version 'tarball' %}">Django-{{ current_version }}.tar.gz</a> (<a href="{% url 'download-redirect' current_version 'checksum' %}">checksums</a>). Then:</p>
-<pre class="literal-block"><code>tar xzvf Django-1.5.tar.gz
-cd Django-1.5
+<pre class="literal-block"><code>tar xzvf Django-{{ current_version }}.tar.gz
+cd Django-{{ current_version }}
sudo python install</code></pre>
<p>You can also use <a href="">pip</a>:
-<pre class="literal-block"><code>pip install Django==1.5</code></pre>
+<pre class="literal-block"><code>pip install Django=={{ current_version }}</code></pre>
<h2>Option 2. Get the latest development version</h2>
@@ -43,7 +43,7 @@
{% block content-related %}
<h2>For the impatient:</h2>
- <li>Latest release: <a href="">Django-1.5.tar.gz</a><br>Checksum: <a href="">Django-1.5.checksum.txt</a></li>
+ <li>Latest release: <a href="{% url 'download-redirect' current_version 'tarball' %}">Django-{{ current_version }}.tar.gz</a><br>Checksum: <a href="{% url 'download-redirect' current_version 'checksum' %}">Django-{{ current_version }}.checksum.txt</a></li>
<h2>Which version is better?</h2>
@@ -52,14 +52,13 @@
<p>If you're just looking for a stable deployment target and don't mind waiting for the next release, you'll want to stick with the latest official release (which will always include detailed notes on any changes you'll need to make while upgrading).</p>
<h2>Previous releases</h2>
- <li>Django 1.4.5: <a href="">Django-1.4.5.tar.gz</a><br>Checksum: <a href="">Django-1.4.5.checksum.txt</a></li>
+ <li>Django {{ previous_version }}: <a href="{% url 'download-redirect' previous_version 'tarball' %}">Django-{{ previous_version }}.tar.gz</a><br>Checksum: <a href="{% url 'download-redirect' previous_version 'checksum' %}">Django-{{ previous_version }}.checksum.txt</a></li>
<h2>Unsupported previous releases (no longer receive security updates or bugfixes)</h2>
- <li>Django 1.3: <a href="">Django-1.3.7.tar.gz</a><br>Checksum: <a href="">Django-1.3.7.checksum.txt</a></li>
- <li>Django 1.2: <a href="">Django-1.2.7.tar.gz</a><br>Checksum: <a href="">Django-1.2.7.checksum.txt</a></li>
- <li>Django 1.1: <a href="">Django-1.1.4.tar.gz</a><br>Checksum: <a href="">Django-1.1.4.checksum.txt</a></li>
- <li>Django 1.0: <a href="">Django-1.0.4.tar.gz</a><br>Checksum: <a href="">Django-1.0.4.checksum.txt</a></li>
+ {% for earlier_version in earlier_versions %}
+ <li>Django {{ earlier_version }}: <a href="{% url 'download-redirect' earlier_version 'tarball' %}">Django-{{ earlier_version }}.tar.gz</a><br>Checksum: <a href="{% url 'download-redirect' earlier_version 'checksum' %}">Django-{{ earlier_version }}.checksum.txt</a></li>
+ {% endfor %}
{% endblock %}

0 comments on commit 1a94ced

Please sign in to comment.
Something went wrong with that request. Please try again.