I want to fire up the django shell with a temporary database (like what's done when doing django tests)
Is there any command like:
python manage.py testshell
where I can create a bunch of bogus models without polluting my database?
00:15 For this, I head over to my terminal, in here. I'm going to start the Django shell by typing python manage.py —as so often—and then shell . This opens up a terminal. 00:30 However, it has the Django settings already imported, so it allows you to work directly from the root folder of a Django project.
Django can be installed easily using pip . In the command prompt, execute the following command: pip install django . This will download and install Django. After the installation has completed, you can verify your Django installation by executing django-admin --version in the command prompt.
Nevermind, this blog post explains it
>>> from django import test
>>> test.utils.setup_test_environment() # Setup the environment
>>> from django.db import connection
>>> db = connection.creation.create_test_db() # Create the test db
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With