id summary reporter owner description type status component version severity resolution keywords cc stage has_patch needs_docs needs_tests needs_better_patch easy ui_ux 24951 Error deleting from table with Foreign Key being Primary Key at the same point Serge Travin nobody "Problem occurs, when trying to issue delete on queryset for a table like this: {{{ class Derivative(models.Model): spot = models.OneToOneField(Spot, primary_key=True) flag = models.BooleanField(default=True) Derivative.objects.filter(spot__name__icontains='name').delete() }}} Result is: AssertionError: Can only delete from one table at a time. However, if we have simple table like this: {{{ class SimpleDerivative(models.Model): spot = models.OneToOneField(Spot) flag = models.BooleanField(default=True) }}} than there is no problem. Note, there is no primary_key for spot here. Problem does not exist for Django 1.6 (I didn't check for previous versions) And persits in 1.7 and 1.8 There is changed code between versions in: django/db/models/sql/subqueries.py - DeleteQuery.delete_qs right before the last line self.tables contains two tables, which leads to assertion error. I provided sample project to reproduce issue - https://github.com/grumbler/django_delete_issue Simply run the tests with the appropriate Django version installed." Bug closed Database layer (models, ORM) 1.8 Release blocker fixed hv@… Accepted 1 0 0 1 0 0