#13240: Modify RelatedManager and ManyRelatedManager add() and remove() to
accept
QuerySets
---------------------------------------------------+------------------------
Reporter: gabrielhurley | Owner:
gabrielhurley
Status: assigned | Milestone: 1.3
Component: Database layer (models, ORM) | Version: SVN
Resolution: | Keywords:
Stage: Ready for checkin | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
---------------------------------------------------+------------------------
Changes (by modulatrix):
* needs_better_patch: 0 => 1
Comment:
Agree that this should be fixed, but this patch seems incomplete - add()
and remove() should accept any arbitrary sequence (e.g. a list or tuple)
as well, not just QuerySets.
E.g., in 1.1:
{{{
# this works (extra args)
user_instance.groups.add(Group.objects.get(name="Group 1"),
Group.objects.get(name="Group 2"))
# this doesn't work (list)
groups_to_add = [Group.objects.get(name="Group 1"),
Group.objects.get(name="Group 2")]
user_instance.groups.add(groups_to_add) # Throws TypeError: unhashable
type: 'list'
# this doesn't work (tuple)
groups_to_add = (Group.objects.get(name="Group 1"),
Group.objects.get(name="Group 2"),)
user_instance.groups.add(groups_to_add) # Throws InterfaceError: Error
binding parameter 1 - probably unsupported type
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/13240#comment:3>
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.