Django: Delete all objects in Model

3 comments

To clear all the data from a django table, simply call:

ModelName.objects.all().delete()

Related Posts

3 comments:

  1. Yeah, it's rather slow, don't You think?

    ReplyDelete
  2. Suppose it does it one by one.

    I haven't taken an in depth look into it because its not something that needs to be done often.

    ReplyDelete

Leave your thoughts ...
---
If you are having trouble with copy/pasting in comments, you need to sign in or click 'Preview'. For more information about this Firefox bug, see here.

 
Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog