Django: Get name of SQL table from Model

It's rare, but sometimes you have to delve deep into the deep edges of Django's ORM to do raw SQL.

Something that would definitely make your life easier is knowing how to get the table name from a models.Model object.

You can fetch it by grabbing YourModel._meta.db_table.

ibvZA3Ux1aA3Nu
Grab that Model, Gangnam style!

 
Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog