How to reset all table contents in django database using view.py or controller?
- Tuesday, February 4, 2014, 20:32
- Django, How-to, Python
- Add a comment
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 following code to your some functions:
Modelname.objects.all().delete()
Here, the Modelname is your django model Class name in Models.py.
Then run the application and make sure that the control reach the line where you added the code just now.
Hope it helps..if so please comment 🙂
About the Author
Write a Comment
Gravatars are small images that can show your personality. You can get your gravatar for free today!