how to delete all instances of a model in django
To delete all instances of a model in Django, you can follow these steps:
Step 1: Import the model from your app:
from myapp.models import YourModel
Step 2: Use the all()
method to retrieve all instances of the model:
instances = YourModel.objects.all()
Step 3: Iterate through the instances and delete each one:
for instance in instances:
instance.delete()