Add a 'clear_db' management command to drop our tables (zephyr + sessions).

(imported from commit 5763983689448944bed13feeeae9a482908a7aff)
This commit is contained in:
Jessica McKellar 2012-08-28 16:56:32 -04:00
parent 4a6402f23c
commit 5dd9616f51
1 changed files with 15 additions and 0 deletions

View File

@ -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")