Tuesday, March 27, 2012

get all models for app with ContentType

How do I get all the models for an app with ContentType?

I have this code the works on the local server but throws
"DoesNotExist: ContentType matching query does not exist" in
production:
ct = ContentType.objects.get(app_label=app_label, name=modelName)

This works:
ct = ContentType.objects.get(app_label)

So it has to be something to do with the modelName. How do can I
print out all the models for this app with ContentType.

I've tried the following at the model appears to be there:
app = get_app(app_label)
for model in get_models(app):

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment