diff --git a/zephyr/management/commands/clear_db.py b/zephyr/management/commands/clear_db.py new file mode 100644 index 0000000000..a9008fd218 --- /dev/null +++ b/zephyr/management/commands/clear_db.py @@ -0,0 +1,15 @@ +from django.core.management.base import NoArgsCommand + +from django.contrib.auth.models import User +from zephyr.models import Zephyr, UserProfile, ZephyrClass, Recipient +from django.contrib.sessions.models import Session + +class Command(NoArgsCommand): + help = "Clear only tables we change: zephyr + sessions" + + def handle_noargs(self, **options): + for klass in [Zephyr, ZephyrClass, UserProfile, User, Recipient]: + klass.objects.all().delete() + Session.objects.all().delete() + + self.stdout.write("Successfully cleared the database.\n")