Opened 8 years ago

Closed 7 years ago

Last modified 5 years ago

#10074 closed (worksforme)

Can't delete objects with lazy GenericRelations

Reported by: clay Owned by: nobody
Component: Database layer (models, ORM) Version: 1.0
Severity: Keywords: genericrelation delete
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by ramiro)

Models with GenericRelation fields defined as:

the_relation = generic.GenericRelation('Related')

produce objects that cannot be deleted:

>>> obj.delete()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "lib/django/db/models/", line 463, in delete
  File "lib/django/db/models/", line 867, in delete_objects
  File "lib/django/db/models/sql/", line 61, in delete_batch_related
    field =
AttributeError: 'str' object has no attribute '_meta'

Attachments (1)

lazy-generic-rel.diff (2.0 KB) - added by Alex 7 years ago.
I can't reproduce with the above, have I misunderstood the bug report?

Download all attachments as: .zip

Change History (5)

comment:1 Changed 8 years ago by ramiro

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

(edited description)

comment:2 Changed 7 years ago by jacob

  • milestone set to 1.1
  • Triage Stage changed from Unreviewed to Accepted

I'm pretty sure the bug here is that generic relations aren't correctly accepting strings and need an actual class.

Changed 7 years ago by Alex

I can't reproduce with the above, have I misunderstood the bug report?

comment:3 Changed 7 years ago by jacob

  • Resolution set to worksforme
  • Status changed from new to closed

Alex can't reproduce; neither can I.

comment:4 Changed 5 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

Note: See TracTickets for help on using tickets.
Back to Top