Skip to content

Commit

Permalink
Django 1.2 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
fle committed Dec 15, 2014
1 parent 77f8841 commit 2c25709
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
7 changes: 7 additions & 0 deletions .travis.yml
Expand Up @@ -8,6 +8,7 @@ python:
- 3.4

env:
- DJANGO_VERSION=1.2
- DJANGO_VERSION=1.3
- DJANGO_VERSION=1.4
- DJANGO_VERSION=1.5
Expand Down Expand Up @@ -44,6 +45,12 @@ after_success:
# We need to exclude old versions of Python for tests with Django >= 1.7.
matrix:
exclude:
- python: 3.2
env: DJANGO_VERSION=1.2
- python: 3.3
env: DJANGO_VERSION=1.2
- python: 3.4
env: DJANGO_VERSION=1.2
- python: 3.2
env: DJANGO_VERSION=1.3
- python: 3.3
Expand Down
28 changes: 21 additions & 7 deletions safedelete/admin.py
Expand Up @@ -10,7 +10,14 @@
from django.contrib.admin.util import model_ngettext
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import PermissionDenied
from django.template.response import TemplateResponse

try:
# Django >= 1.3
from django.template.response import TemplateResponse
except ImportError:
from django.shortcuts import render_to_response
from django.template import RequestContext

try:
# Django > 1.3
from django.utils.encoding import force_text
Expand Down Expand Up @@ -137,10 +144,17 @@ def undelete_selected(self, request, queryset):
'action_checkbox_name': helpers.ACTION_CHECKBOX_NAME,
}

return TemplateResponse(
request,
self.undelete_selected_confirmation_template,
context,
current_app=self.admin_site.name,
)
if django.VERSION[1] < 3:
return render_to_response(
self.undelete_selected_confirmation_template,
context,
context_instance=RequestContext(request))
else:
return TemplateResponse(
request,
self.undelete_selected_confirmation_template,
context,
current_app=self.admin_site.name,
)

undelete_selected.short_description = _("Undelete selected %(verbose_name_plural)s.")

0 comments on commit 2c25709

Please sign in to comment.