I need to retrive table name and model’s contenttype id for all model of a specific app. I can use this code to get a model’s table name, but not its contenttype id:
from django.db.models import get_app, get_models
app = get_app("my_app_name")
for model in get_models(app, include_auto_created=True):
print model._meta.db_table
However I need to directly get this information from database. Something like:
Select id, model from django_content_type where app_label='my_app_name'
In this case, I get id but not table name. Where to get table name in 2nd case?
To get the pk of the contenttype of a model
To run standalone Django script, refs posts or simply (which normally works)