clear data for one app

linkaiyi
Follow

clear data just for one app

do it after dump all data for backup reason

python manage.py migrate <app> zero # clear data and delete table
python manage.py migrate <app> # migrate again
invalidate all cache # in case of using cacheops

in case of migration conflict or database errors, use following code to clear data

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()
Object has 0 attachments

Was this article helpful?

This article is viewed 17 times!

Recent Viewed Articles

Related Articles

0 Comments

Leave a Comment

Support