Hello, I've encountered what may be a Django ORM bug and am writing to see what the dev community thinks. I have a model that uses generic relations<https://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#generic-relations>. An error is returned when I attempt to delete multiple rows of said model in the database table. The error is repeatable, and I have found it is only applicable to models that contain generic relations. The error occurs after the deletion is confirmed in the admin interface and the SQL statement begins execution.
I've attached the use case that creates the bug, the generated SQL statement (read from the debug output), and the model in question. Could someone please confirm that this is indeed a bug? If so, I can create a ticket and begin researching how to remedy this problem. -- Dylan -- You received this message because you are subscribed to the Google Groups "Django developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To post to this group, send email to django-developers@googlegroups.com. Visit this group at http://groups.google.com/group/django-developers?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
DELETE FROM "NANOFAB_ACTIVITYHISTORY" WHERE "ID" IN (SELECT "NANOFAB_ACTIVITYHISTORY"."ID" FROM "NANOFAB_ACTIVITYHISTORY" INNER JOIN "DJANGO_CONTENT_TYPE" ON ("NANOFAB_ACTIVITYHISTORY"."CONTENT_TYPE_ID" = "DJANGO_CONTENT_TYPE"."ID") INNER JOIN "NANOFAB_USER" ON ("NANOFAB_ACTIVITYHISTORY"."AUTHORIZER_ID" = "NANOFAB_USER"."ID") WHERE "NANOFAB_ACTIVITYHISTORY"."ID" IN (:arg0, :arg1) ORDER BY "NANOFAB_ACTIVITYHISTORY"."DATE" DESC Note, the bindings in this statement are :arg0 = 3 and :arg = 2
<<attachment: Use case to create bug.png>>
class ActivityHistory(models.Model): """ Stores the history of when accounts, projects, and users are active. This class uses generic relations in order to point to any model type. For more information see: https://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#generic-relations """ class Action: ACTIVATED = True DEACTIVATED = False Choices = ( (ACTIVATED, 'Activated'), (DEACTIVATED, 'Deactivated'), ) content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() content_object = generic.GenericForeignKey('content_type', 'object_id') action = models.BooleanField(choices=Action.Choices, help_text="The target state (activated or deactivated).") date = models.DateTimeField(default=timezone.now, help_text="The time at which the active state was changed.") authorizer = models.ForeignKey(User, help_text="The staff member who changed the active state of the account, project, or user in question.") class Meta: ordering = ['-date'] verbose_name_plural = 'activity histories' def __unicode__(self): if self.action: state = "activated" else: state = "deactivated" return unicode(self.content_type).capitalize() + " " + unicode(self.object_id) + " " + state