#10074: Can't delete objects with lazy GenericRelations
---------------------------------------------------+------------------------
          Reporter:  clay                          |         Owner:  nobody     
           
            Status:  new                           |     Milestone:             
           
         Component:  Database layer (models, ORM)  |       Version:  1.0        
           
        Resolution:                                |      Keywords:  
genericrelation delete
             Stage:  Unreviewed                    |     Has_patch:  0          
           
        Needs_docs:  0                             |   Needs_tests:  0          
           
Needs_better_patch:  0                             |  
---------------------------------------------------+------------------------
Changes (by ramiro):

  * needs_better_patch:  => 0
  * needs_tests:  => 0
  * needs_docs:  => 0

Old description:

> 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/base.py", line 463, in delete
>     delete_objects(seen_objs)
>   File "lib/django/db/models/query.py", line 867, in delete_objects
>     del_query.delete_batch_related(pk_list)
>   File "lib/django/db/models/sql/subqueries.py", line 61, in
> delete_batch_related
>     field = f.rel.to._meta.get_field(f.content_type_field_name)
> AttributeError: 'str' object has no attribute '_meta'

New description:

 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/base.py", line 463, in delete
     delete_objects(seen_objs)
   File "lib/django/db/models/query.py", line 867, in delete_objects
     del_query.delete_batch_related(pk_list)
   File "lib/django/db/models/sql/subqueries.py", line 61, in
 delete_batch_related
     field = f.rel.to._meta.get_field(f.content_type_field_name)
 AttributeError: 'str' object has no attribute '_meta'
 }}}

Comment:

 (edited description)

-- 
Ticket URL: <http://code.djangoproject.com/ticket/10074#comment:1>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to