Skip to content

Commit

Permalink
each_context not documented in Django 1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
brianmay committed Feb 23, 2016
1 parent b6a1c58 commit 06dc479
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions guardian/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import unicode_literals

import django
from django import forms
from django.conf import settings
from guardian.compat import url
Expand Down Expand Up @@ -119,10 +120,13 @@ def get_urls(self):
def get_obj_perms_base_context(self, request, obj):
"""
Returns context dictionary with common admin and object permissions
related content. It uses AdminSite.each_context (available in Django >= 1.7,
related content. It uses AdminSite.each_context (available in Django >= 1.8,
making sure all required template vars are in the context.
"""
context = self.admin_site.each_context(request) if hasattr(self.admin_site, 'each_context') else {}
if django.VERSION >= (1, 8):
context = self.admin_site.each_context(request)
else:
context = {}
context.update( {
'adminform': {'model_admin': self},
'media': self.media,
Expand Down

0 comments on commit 06dc479

Please sign in to comment.