14
For a given instance
, you can use instance._meta.db_table
but that also works for the model class too, so if you can step up from the manager to its model
, that’ll work too
- [Django]-Best practices for adding .gitignore file for Python projects?
- [Django]-How to add Indian Standard Time (IST) in Django?
- [Django]-Define css class in django Forms
11
Let’s say you have a model named Service
You can use
Service._meta.db_table # this will work too
This as well
Service.objects.model._meta.db_table # this will work too
This as well
Let’s say you had an instance of the service Model
like this
service = Service.objects.get(pk=1)
# get table name like this
table_name = service._meta.db_table # this will work too
- [Django]-Sending post data from angularjs to django as JSON and not as raw content
- [Django]-Why use Django on Google App Engine?
- [Django]-How to revert the last migration?
Source:stackexchange.com