Ticket #3263: newforms_models.diff

File newforms_models.diff, 768 bytes (added by Jeff Hilyard <jhilyard@…>, 8 years ago)

Suggested patch

  • newforms/models.py

     
    3333    if form.errors:
    3434        raise ValueError("The %s could not be changed because the data didn't validate." % opts.object_name)
    3535    clean_data = form.clean_data
    36     for f in opts.fields + opts.many_to_many:
     36    for f in opts.fields:
    3737        if isinstance(f, models.AutoField):
    3838            continue
    3939        setattr(instance, f.attname, clean_data[f.name])
     40    for f in opts.many_to_many:
     41        setattr(instance, f.attname, getattr(instance, f.attname).model.objects.filter(pk__in = clean_data[f.name]))
    4042    if commit:
    4143        instance.save()
    4244    return instance
Back to Top