How to clear a database from the CLI with manage.py in Django?

0 votes
I am using Django to build a website with MySQL. Now as I am learning so I need to change the Model very often so I want that all tables get cleared and new table get created.

But syncdb doesn't touch existing tables. Is there any better way to handle this problem?
Aug 7 in Python by kartik
• 27,780 points
81 views

1 answer to this question.

0 votes

Hello @kartik,

To drop the database and run syncdb again. Or you can run:

For Django >= 1.5

python manage.py flush

For Django < 1.5

python manage.py reset appname

Hope this help!!

Thank You!!

answered Aug 7 by Niroj
• 59,780 points

Related Questions In Python

0 votes
1 answer
0 votes
1 answer

How to order_by a JSON from serializers.py file in django rest framework?

Hello @kartik, There's an easy way, just override ...READ MORE

answered Jul 1 in Python by Niroj
• 59,780 points
149 views
0 votes
0 answers
0 votes
2 answers
0 votes
1 answer

How to temporarily disable a foreign key constraint in MySQL?

Hello @kartik, To turn off foreign key constraint ...READ MORE

answered Jun 23 in Python by Niroj
• 59,780 points
192 views
0 votes
1 answer

How do I use Django templates without the rest of Django?

Hello @kartik, Let's say you have this important ...READ MORE

answered Jun 23 in Python by Niroj
• 59,780 points
83 views
0 votes
1 answer
0 votes
1 answer

How to output text from database with line breaks in a django template?

Hello @kartik, Use linebreaks or linebreaksbr filter: {{ text|linebreaks }} Or surround the text ...READ MORE

answered Jun 24 in Python by Niroj
• 59,780 points
280 views