Skip to content

Commit

Permalink
Remove hardcoded version numbers from the download page.
Browse files Browse the repository at this point in the history
  • Loading branch information
aaugustin committed Mar 14, 2013
1 parent b1dbfa6 commit 1a94ced
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 15 deletions.
6 changes: 3 additions & 3 deletions releases/urls.py
@@ -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 changes: 13 additions & 1 deletion releases/views.py
Expand Up @@ -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):
Expand Down
21 changes: 10 additions & 11 deletions templates/releases/download.html
Expand Up @@ -13,17 +13,17 @@ <h1>How to get Django</h1>

<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="https://www.djangoproject.com/download/1.5/tarball/">Django-1.5.tar.gz</a> (<a href="https://www.djangoproject.com/download/1.5/checksum/">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 setup.py install</code></pre>

<p>You can also use <a href="http://www.pip-installer.org/en/latest/">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>

Expand All @@ -43,7 +43,7 @@ <h2>After you get it</h2>
{% block content-related %}
<h2>For the impatient:</h2>
<ul>
<li>Latest release: <a href="https://www.djangoproject.com/download/1.5/tarball/">Django-1.5.tar.gz</a><br>Checksum: <a href="https://www.djangoproject.com/download/1.5/checksum/">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>
</ul>

<h2>Which version is better?</h2>
Expand All @@ -52,14 +52,13 @@ <h2>Which version is better?</h2>
<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>
<ul>
<li>Django 1.4.5: <a href="https://www.djangoproject.com/download/1.4.5/tarball/">Django-1.4.5.tar.gz</a><br>Checksum: <a href="https://www.djangoproject.com/download/1.4.5/checksum/">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>
</ul>

<h2>Unsupported previous releases (no longer receive security updates or bugfixes)</h2>
<ul>
<li>Django 1.3: <a href="https://www.djangoproject.com/download/1.3.7/tarball/">Django-1.3.7.tar.gz</a><br>Checksum: <a href="https://www.djangoproject.com/download/1.3.7/checksum/">Django-1.3.7.checksum.txt</a></li>
<li>Django 1.2: <a href="https://www.djangoproject.com/download/1.2.7/tarball/">Django-1.2.7.tar.gz</a><br>Checksum: <a href="https://www.djangoproject.com/download/1.2.7/checksum/">Django-1.2.7.checksum.txt</a></li>
<li>Django 1.1: <a href="https://www.djangoproject.com/download/1.1.4/tarball/">Django-1.1.4.tar.gz</a><br>Checksum: <a href="https://www.djangoproject.com/download/1.1.4/checksum/">Django-1.1.4.checksum.txt</a></li>
<li>Django 1.0: <a href="https://www.djangoproject.com/download/1.0.4/tarball/">Django-1.0.4.tar.gz</a><br>Checksum: <a href="https://www.djangoproject.com/download/1.0.4/checksum/">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 %}
</ul>
{% endblock %}

0 comments on commit 1a94ced

Please sign in to comment.