django clear db

Step 1: Open a terminal or command prompt.

Step 2: Navigate to the root directory of your Django project.

Step 3: Run the following command to create a database migration:

python manage.py makemigrations

Step 4: Apply the database migration to update the database schema:

python manage.py migrate

Step 5: Run the following command to clear the database:

python manage.py flush

Step 6: Confirm the action by typing 'yes' when prompted.

Step 7: If your project uses South for migrations, run the following command to delete the database and recreate it:

python manage.py migrate --fake

Step 8: Finally, create a new superuser for the empty database:

python manage.py createsuperuser

Step 9: Follow the prompts to set up the superuser account.

Your Django database is now cleared, and you can proceed with your project using a fresh database.