misc: workaround migration order, lazy load cells if contenttypes is not ready
This commit is contained in:
parent
140d5d5393
commit
382ee37f12
|
@ -31,11 +31,22 @@ class Library(object):
|
|||
# initialize the dictionary
|
||||
self.classes_by_content_str = {}
|
||||
for klass in self.classes:
|
||||
content_type = ContentType.objects.get_for_model(klass)
|
||||
try:
|
||||
content_type = ContentType.objects.get_for_model(klass)
|
||||
except RuntimeError:
|
||||
# this is for RuntimeError: Error creating new content types.
|
||||
# Please make sure contenttypes is migrated before trying to
|
||||
# migrate apps individually.
|
||||
#
|
||||
# If that happens we switch to lazy initialization.
|
||||
self.classes_by_content_str = None
|
||||
break
|
||||
content_type_str_v = '%s_%s' % (content_type.app_label, content_type.model)
|
||||
self.classes_by_content_str[content_type_str_v] = klass
|
||||
|
||||
def get_cell_class(self, content_type_str):
|
||||
if self.classes_by_content_str is None:
|
||||
self.ready()
|
||||
return self.classes_by_content_str[content_type_str]
|
||||
|
||||
def register_cell_class(self, klass):
|
||||
|
|
Loading…
Reference in New Issue