Skip to content

Commit

Permalink
Merge pull request #239 from manelclos/admin_site_header
Browse files Browse the repository at this point in the history
update context with admin vars. Fixes #213
  • Loading branch information
bmihelac committed Apr 15, 2015
2 parents e974b6b + aa8e7f4 commit 1d2da43
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions import_export/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from datetime import datetime
import os.path

import django
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from django.conf.urls import patterns, url
Expand Down Expand Up @@ -211,6 +212,11 @@ def import_action(self, request, *args, **kwargs):
'input_format': form.cleaned_data['input_format'],
})

if django.VERSION >= (1, 8, 0):
context.update(self.admin_site.each_context(request))
elif django.VERSION >= (1, 7, 0):
context.update(self.admin_site.each_context())

context['form'] = form
context['opts'] = self.model._meta
context['fields'] = [f.column_name for f in resource.get_fields()]
Expand Down Expand Up @@ -324,6 +330,12 @@ def export_action(self, request, *args, **kwargs):
return response

context = {}

if django.VERSION >= (1, 8, 0):
context.update(self.admin_site.each_context(request))
elif django.VERSION >= (1, 7, 0):
context.update(self.admin_site.each_context())

context['form'] = form
context['opts'] = self.model._meta
return TemplateResponse(request, [self.export_template_name],
Expand Down

0 comments on commit 1d2da43

Please sign in to comment.