python manage.py flush
removes data from the entire project. I would like to be able to do python manage.py flush agivenapp
How can I do this?
For later versions of Django try in the Django shell:
from django.apps import apps
my_app = apps.get_app_config('my_app_name')
my_models = my_app.get_models()
for model in my_models:
model.objects.all().delete()
More on the apps
module can be found here.
Of course, you could convert this to a management command yourself using the management infrastructure.