Skip to content
Browse files

Improved newforms.models.save_for_instance() to set many-to-many valu…

…es via ID instead of instance, to save on a database query, thanks to [4448]

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent d28a63c commit 5aea495ac3a000a7b72fa3202e05ff35676e0e4e @adrianholovaty adrianholovaty committed
Showing with 1 addition and 1 deletion.
  1. +1 −1  django/newforms/
2  django/newforms/
@@ -37,7 +37,7 @@ def save_instance(form, instance, commit=True):
if commit:
for f in opts.many_to_many:
- setattr(instance, f.attname, getattr(instance, f.attname).model.objects.filter(pk__in = clean_data[]))
+ setattr(instance, f.attname, clean_data[])
# GOTCHA: If many-to-many data is given and commit=False, the many-to-many
# data will be lost. This happens because a many-to-many options cannot be
# set on an object until after it's saved. Maybe we should raise an

0 comments on commit 5aea495

Please sign in to comment.
Something went wrong with that request. Please try again.