I want to alter my model but before doing so I want to delete all the records from my database, is there any dajngo ORM query for doing that cuz I don't want to do it manually. Thanks.
I tried to alter my model but when I migrated the changes an error occured. it was a long error but the last line was this.
File "C:\\Users\\ALI SHANAWER.virtualenvs\\PiikFM-App-Backend-O_dKS6jY\\Lib\\site-packages\\MySQLdb\\connections.py", line 254, in query \_mysql.connection.query(self, query) django.db.utils.OperationalError: (3140, 'Invalid JSON text: "Invalid value." at position 0 in value for column '#sql-45_2d01.qbo_class'.')
any one knows what this is?
CodePudding user response:
You can simple delete db.sqlite ie, database file
then run python manage.py makemigration and then python manage.py migrate.
I hope this is what you were looking for
CodePudding user response:
If you want to truncate only a single table then use {ModelName}.objects.all().delete() otherwise use can use "python manage.py flush" for truncate database.