Flush just an app not the whole project

前端 未结 4 461
感动是毒
感动是毒 2021-02-04 01:08

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?

4条回答
  •  一向
    一向 (楼主)
    2021-02-04 01:58

    You can do this with the migrate command which takes two positional arguments:

    Updates database schema. Manages both apps with migrations and those without.

    positional arguments:

    app_label
    App label of an application to synchronize the state.
    migration_name
    Database state will be brought to the state after that migration. Use the name "zero" to unapply all migrations.

    So running a migrate zero followed by a migrate will clear only the data for the given app.

    $ python manage.py migrate ${APPNAME} zero
    $ python manage.py migrate ${APPNAME}    
    

提交回复
热议问题