How to remove all of the data in a table using Django

后端 未结 8 1757
执笔经年
执笔经年 2020-12-12 21:12

I have two questions:

  1. How do I delete a table in Django?
  2. How do I remove all the data in the table?

This is my code, which is not succe

相关标签:
8条回答
  • 2020-12-12 22:08

    As per the latest documentation, the correct method to call would be:

    Reporter.objects.all().delete()
    
    0 讨论(0)
  • 2020-12-12 22:11

    If you want to remove all the data from all your tables, you might want to try the command python manage.py flush. This will delete all of the data in your tables, but the tables themselves will still exist.

    See more here: https://docs.djangoproject.com/en/1.8/ref/django-admin/

    0 讨论(0)
提交回复
热议问题