Question: `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?

Answer: 
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](https://docs.djangoproject.com/en/dev/ref/applications/).
Of course, you could convert this to a management command yourself using the management [infrastructure](https://docs.djangoproject.com/en/dev/howto/custom-management-commands/).
I also needed something to empty only certain apps. I came up with this solution. This worked for mysql. It could be that the code needs to be changed for other databases.

The main idea is not to do the whole 'flush'. Instead I get only what I want, with a grep from 'sqlflush'. You can also put everything in one line. For readability I split it up. 

```
BEGIN="BEGIN; SET FOREIGN_KEY_CHECKS = 0;"
TRUNCATE=`./manage.py sqlflush |egrep " \\\`app1_| \\\`app2_"`
END="SET FOREIGN_KEY_CHECKS = 1; COMMIT;"

echo $BEGIN $TRUNCATE $END | ./manage.py dbshell

```