| 1 | import os |
| 2 | from django.core.management import call_command |
| 3 | from django.core.management.base import BaseCommand |
| 4 | from optparse import make_option |
| 5 | |
| 6 | class Command(BaseCommand): |
| 7 | option_list = BaseCommand.option_list + ( |
| 8 | make_option('--plain', action='store_true', dest='plain', |
| 9 | help='Tells Django to use plain Python, not IPython.'), |
| 10 | ) |
| 11 | help = "Runs a Python interactive interpreter. Tries to use IPython, if it's available." |
| 12 | shells = ['ipython', 'bpython'] |
| 13 | requires_model_validation = False |
| 14 | |
| 15 | def handle(self, *args, **options): |
| 16 | print 'Using test database' |
| 17 | from django.db import connection |
| 18 | connection.creation.create_test_db() |
| 19 | |
| 20 | use_plain = options.get('plain', False) |
| 21 | |
| 22 | call_command('shell', plain=use_plain) |