Here's the models: # models.py class Article(models.Model): title = models.CharField(max_length=100)
# urls.py urlpatterns = patterns('', (r'^delete-rolledback/$', delete_rolledback), ) # views.py def delete_rolledback(request): transaction.enter_transaction_management() transaction.managed(True) qs = Article.objects.all() for article in qs: if article.title.lower().startswith(request.GET.get ('startswith')): article.delete() break transaction.rollback() return HttpResponse("Rolled back!") # tests.py from django.test import TestCase from news.models import Article class SimpleTest(TestCase): def setUp(self): Article.objects.create(title=u'Abraham') Article.objects.create(title=u'Ben') Article.objects.create(title=u'Ancor') Article.objects.create(title=u'Wat') super(SimpleTest, self).setUp() def test_deletion(self): count_before = Article.objects.count() assert count_before == 4 r = self.client.get('/news/delete-rolledback/', dict(startswith='a')) assert r.content.count("Rolled back") count_after = Article.objects.count() assert count_after == 4, count_after When I run these tests (with postgres or with sqlite) I get this assertion error: Traceback (most recent call last): ... AssertionError: 3 If someone more clued up than me could take a look at this and confirm that it is a Django bug I can start looking into explaining what's wrong and possibilities of a patch. I've found this ticket (http://code.djangoproject.com/ticket/4758) where someone has experienced similar problems when using Oracle. But only for Oracle; he claims the same code *works* with Postgres. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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 -~----------~----~----~----~------~----~------~--~---