Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Django 1.4 compatibility with inlines in tabs

  • Loading branch information...
commit d43988a90789e07e6dba161553784895f5de9075 1 parent 8788569
@evildmp evildmp 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:

2 comments on commit d43988a

@timsloan

Thanks for fixing this. Saved me some hair-pulling.

@evildmp

We need all the hair we can keep.

Please sign in to comment.
Something went wrong with that request. Please try again.