[Solved]-Start django shell with a temporary database

22👍

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
👤Ben

-2👍

You could just turn autocommit off:

from django.db import transaction
transaction.set_autocommit(False)

Leave a comment