Files
zulip/zephyr/management/commands/clear_db.py
Tim Abbott 95f95d7e54 klass => model as a local variable to refer to our models.
(imported from commit c58a3133bfd8db13d34f8def4cf73e7526214e8e)
2012-10-10 17:47:12 -04:00

18 lines
689 B
Python

from django.core.management.base import NoArgsCommand
from django.contrib.auth.models import User
from zephyr.models import Message, UserProfile, Stream, Recipient, \
Subscription, Huddle, Realm, UserMessage
from django.contrib.sessions.models import Session
class Command(NoArgsCommand):
help = "Clear only tables we change: messages, accounts + sessions"
def handle_noargs(self, **options):
for model in [Message, Stream, UserProfile, User, Recipient,
Realm, Subscription, Huddle, UserMessage]:
model.objects.all().delete()
Session.objects.all().delete()
self.stdout.write("Successfully cleared the database.\n")