﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
18548	View changes field when 'unique_together' is not satisfied in a Form	anonymous	nobody	"I have a Model called Person with the following constraint: unique_together = ('name', 'country')

Furthermore I have a view to to edit a Person:

{{{
def edit_climbing_place(request, person_id):

    person = get_object_or_404(Person, pk=person_id)

    print person.name

    if not request.method == 'POST':
        form     = Person(instance=place)

    else:
        form = Person(request.POST, instance=place)

        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse(start_page))
     

    print person.name

    return render_to_response('myProject/edit_person.html',
        {'form' : form, 'person': person},
        context_instance=RequestContext(request))
}}}

In the above code if form.is_valid() fails due to the 'unique_together' constraint is not satisfied then the two 'print person.name' outputs are different. In other words if I edit an existing 'Person' (say A) and change the name to a name which matches an already existing person (say B) in the same 'country' then in the above view the variable 'person.name' changes to that of B. All other fields, however, stay the same."	Cleanup/optimization	closed	Documentation	1.4	Normal	fixed		timograham@…	Accepted	1	0	0	0	0	0
