{"id":130,"date":"2014-02-04T20:32:20","date_gmt":"2014-02-04T20:32:20","guid":{"rendered":"http:\/\/rat32.com\/rat32\/?p=130"},"modified":"2014-02-04T20:37:12","modified_gmt":"2014-02-04T20:37:12","slug":"how-to-reset-all-table-contents-in-django-database","status":"publish","type":"post","link":"https:\/\/rat32.com\/rat32\/2014\/02\/04\/how-to-reset-all-table-contents-in-django-database\/","title":{"rendered":"How to reset all table contents in django database using view.py or controller?"},"content":{"rendered":"<p>Sometimes we need to delete or truncate all the database tables in django project from the view.py or controller file.<br \/>\nFirst of all you need to go to open the view.py and add the following code to your some functions:<\/p>\n<p><code><br \/>\nModelname.objects.all().delete()<br \/>\n<\/code><\/p>\n<p>Here, the Modelname is your django model Class name in Models.py.<br \/>\nThen run the application and make sure that the control reach the line where you added the code just now.<\/p>\n<p>Hope it helps..if so please comment \ud83d\ude42<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Sometimes we need to delete or truncate all the database tables in django project from the view.py or controller file. First of all you need to go to open the view.py and add the&#46;&#46;&#46;<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[44,7,9],"tags":[59,54,55,51,60,52,58,61,53,57,56,62],"class_list":["post-130","post","type-post","status-publish","format-standard","hentry","category-django","category-how-to","category-python","tag-command","tag-database","tag-delete","tag-django-2","tag-django-admin","tag-how-to-2","tag-manage-py","tag-models-py","tag-reset","tag-table","tag-truncate","tag-view-py"],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/rat32.com\/rat32\/wp-json\/wp\/v2\/posts\/130"}],"collection":[{"href":"https:\/\/rat32.com\/rat32\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rat32.com\/rat32\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rat32.com\/rat32\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rat32.com\/rat32\/wp-json\/wp\/v2\/comments?post=130"}],"version-history":[{"count":3,"href":"https:\/\/rat32.com\/rat32\/wp-json\/wp\/v2\/posts\/130\/revisions"}],"predecessor-version":[{"id":133,"href":"https:\/\/rat32.com\/rat32\/wp-json\/wp\/v2\/posts\/130\/revisions\/133"}],"wp:attachment":[{"href":"https:\/\/rat32.com\/rat32\/wp-json\/wp\/v2\/media?parent=130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rat32.com\/rat32\/wp-json\/wp\/v2\/categories?post=130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rat32.com\/rat32\/wp-json\/wp\/v2\/tags?post=130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}