Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #9 from evildmp/master

Compatibility with Django 1.4 for inlines
  • Loading branch information...
commit 044b0fa6407b5f76082a8205857ef55f410fddb8 2 parents 8788569 + d43988a
@stefanfoulis authored
Showing with 17 additions and 1 deletion.
  1. +17 −1 widgetry/tabs/admin.py
View
18 widgetry/tabs/admin.py
@@ -110,11 +110,27 @@ def __init__(self, model, admin_site):
super(ModelAdminWithTabs, self).__init__(model, admin_site)
# populate self.inline_instances with all inlines defined inside tabs.
- self.inline_instances = []
+
+ # We provide two different ways of doing this here.
+ # The original way populates them in Django < 1.4.
+ # In Django 1.4, a different method is required.
+ #
+ # Since
+ # https://github.com/django/django/commit/b1b1da1eac93297503c04b8394fb98e38f552f5f
+ # django.contrib.admin.options.ModelAdmin.__init__() no longer takes responsibility
+ # for inlines.
+ #
+ # Instead, a get_inline_instances() method takes care of it.
+
+ # the original, for backwards compatibility
+ self.inline_instances = []
for inline_class in self._extract_inlines_from_tabs():
inline_instance = inline_class(self.model, self.admin_site)
self.inline_instances.append(inline_instance)
+ # the way for Django 1.4
+ self.inlines = self._extract_inlines_from_tabs()
+
def _extract_inlines_from_tabs(self):
inlines = []
for name, opts in self.tabs:
Please sign in to comment.
Something went wrong with that request. Please try again.