PageRenderTime 11ms CodeModel.GetById 2ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/pexp/management/commands/pcmd.py

https://bitbucket.org/bconstantin/django_polymorphic/
Python | 39 lines | 30 code | 5 blank | 4 comment | 0 complexity | 7ce1582e456342f5f47ce1cb3e7bccd4 MD5 | raw file
 1# -*- coding: utf-8 -*-
 2"""
 3This module is a scratchpad for general development, testing & debugging.
 4"""
 5
 6from django.core.management.base import NoArgsCommand
 7from django.db.models import connection
 8from pprint import pprint
 9import settings
10
11from pexp.models import *
12
13def reset_queries():
14    connection.queries=[]
15
16def show_queries():
17    print; print 'QUERIES:',len(connection.queries); pprint(connection.queries); print; connection.queries=[]
18
19class Command(NoArgsCommand):
20    help = ""
21
22    def handle_noargs(self, **options):
23        print 'polycmd - sqlite test db is stored in:',settings.SQLITE_DB_PATH
24        print
25
26        Project.objects.all().delete()
27        a=Project.objects.create(topic="John's gathering")
28        b=ArtProject.objects.create(topic="Sculpting with Tim", artist="T. Turner")
29        c=ResearchProject.objects.create(topic="Swallow Aerodynamics", supervisor="Dr. Winter")
30        print Project.objects.all()
31        print
32
33        ModelA.objects.all().delete()
34        a=ModelA.objects.create(field1='A1')
35        b=ModelB.objects.create(field1='B1', field2='B2')
36        c=ModelC.objects.create(field1='C1', field2='C2', field3='C3')
37        print ModelA.objects.all()
38        print
39