I thought so, have tried so, but got "This code isn't under transaction management", and opened this thread :)
Environment: Request Method: GET Request URL: http://localhost:8000/ Django Version: 1.2 beta 1 Python Version: 2.6.4 Installed Applications: ['testapp'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware') Traceback: File "/usr/lib/python2.6/dist-packages/django/core/handlers/base.py" in get_response 100. response = callback(request, *callback_args, **callback_kwargs) File "/home/idle/projects/gitdev/django-tests/testapp/views.py" in test 22. transaction.commit(using='test') File "/usr/lib/python2.6/dist-packages/django/db/transaction.py" in commit 200. set_clean(using=using) File "/usr/lib/python2.6/dist-packages/django/db/transaction.py" in set_clean 125. raise TransactionManagementError("This code isn't under transaction management") Exception Type: TransactionManagementError at / Exception Value: This code isn't under transaction management On 29 апр, 09:07, Russell Keith-Magee <freakboy3...@gmail.com> wrote: > On Thu, Apr 29, 2010 at 12:59 AM, idle sign <idles...@gmail.com> wrote: > > I think I spotted something weird. May be someone could explain that? > > > 1. In Django 1.2 define two DBs (let it be sqlite), one of which name > > 'test'. > > 2. Define DB router for 'testapp' so that it always uses 'test' DB. > > 3. Use 'commit_manually' decorator for 'test' view. > > 4. In 'test' view define 'cursor' pointing to 'test' DB. > > 5. Execute some INSERTs and commit > > *. 'Samples' object (exported from model) would show all inserted > > object, but nothing would be written into DB. > > The problem is on this line: > > > transaction.commit() > > By default (for backwards compatibility), commit() operates on the > default database. If you want to commit results on the 'test' > connection, you need to provide a 'using' argument: > > transaction.commit(using='test') > > Yours, > Russ Magee %-) > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.