content types

This commit is contained in:
Sanj 2011-09-10 04:55:10 +05:30
parent 442b6dadd6
commit 505656c3f3

View File

@ -18,7 +18,7 @@ def splitSearch(string):
#i see the point of this function, but please clean it up: refer to 'except MultipleObjectsReturned' to see why this is here.
def get_real_ctype(module_name):
for c in ContentType.objects.filter(model=module_name):
if c.is_itf_model == True:
if c.model_class().is_itf_model == True:
return c
return None
@ -49,7 +49,8 @@ class ItfModel(models.Model):
except:#FIXME: ideally catch only MultipleObjectsReturned (figure out where to import that from :/ ) #FUCKING way ugly hack to get clashing model ctype names with django internal models working (get_real_ctypes simply checks, if there are multiple content objects with the same 'module_name', which one is_itf_model, and returns that).
ctype = get_real_ctype(self.__class__._meta.module_name)
modelextra = ModelExtra.objects.filter(model=ctype)[0]
# modelextra = ModelExtra.objects.filter(model=ctype)[0]
modelextra = ctype.modelextra_set.all()[0]
tab = ModuleTab.objects.filter(model=modelextra)[0]
return tab