Flush just an app not the whole project

前端 未结 4 466
感动是毒
感动是毒 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 02:01

    sqlclear management command can be helpful...

    Usage: ./manage.py sqlclear [options] 
    
    Prints the DROP TABLE SQL statements for the given app name(s).
    

    for the postgresql you can do:

    ./manage.py sqlclear myapp | psql dbname
    

    UPDATE for apps with migrations and Django 1.7+:

    python manage.py migrate  zero
    

提交回复
热议问题