Re: [Django] #18548: View changes field when 'unique_together' is not satisfied in a Form

2012-10-16 Thread Django
#18548: View changes field when 'unique_together' is not satisfied in a Form
--+
 Reporter:  anonymous |Owner:  nobody
 Type:  Cleanup/optimization  |   Status:  closed
Component:  Documentation |  Version:  1.4
 Severity:  Normal|   Resolution:  fixed
 Keywords:| Triage Stage:  Accepted
Has patch:  1 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+

Comment (by Tim Graham ):

 In [changeset:"6ebb6f918872c2a714ddb9808984e70daaa95cd8"]:
 {{{
 #!CommitTicketReference repository=""
 revision="6ebb6f918872c2a714ddb9808984e70daaa95cd8"
 [1.4.X] Fixed #18548 - Clarified note regarding reusing model instances
 when form validation fails.

 Backport of fd02bcff4a from master
 }}}

-- 
Ticket URL: 
Django 
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 django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Django] #18548: View changes field when 'unique_together' is not satisfied in a Form

2012-10-16 Thread Django
#18548: View changes field when 'unique_together' is not satisfied in a Form
--+
 Reporter:  anonymous |Owner:  nobody
 Type:  Cleanup/optimization  |   Status:  closed
Component:  Documentation |  Version:  1.4
 Severity:  Normal|   Resolution:  fixed
 Keywords:| Triage Stage:  Accepted
Has patch:  1 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+
Changes (by Tim Graham ):

 * status:  reopened => closed
 * resolution:   => fixed


Comment:

 In [changeset:"fd02bcff4aee885d395f2439efdd522c22e40794"]:
 {{{
 #!CommitTicketReference repository=""
 revision="fd02bcff4aee885d395f2439efdd522c22e40794"
 Fixed #18548 - Clarified note regarding reusing model instances when form
 validation fails.
 }}}

-- 
Ticket URL: 
Django 
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 django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Django] #18548: View changes field when 'unique_together' is not satisfied in a Form

2012-10-11 Thread Django
#18548: View changes field when 'unique_together' is not satisfied in a Form
--+
 Reporter:  anonymous |Owner:  nobody
 Type:  Cleanup/optimization  |   Status:  reopened
Component:  Documentation |  Version:  1.4
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  1 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+
Changes (by timo):

 * cc: timograham@… (added)
 * has_patch:  0 => 1


Comment:

 I added the note in the referenced ticket so I think it's clear, but does
 the attached patch help emphasize the point?

-- 
Ticket URL: 
Django 
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 django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Django] #18548: View changes field when 'unique_together' is not satisfied in a Form

2012-07-11 Thread Django
#18548: View changes field when 'unique_together' is not satisfied in a Form
--+
 Reporter:  anonymous |Owner:  nobody
 Type:  Cleanup/optimization  |   Status:  reopened
Component:  Documentation |  Version:  1.4
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+
Changes (by aaugustin):

 * type:  Bug => Cleanup/optimization
 * version:  1.3 => 1.4
 * component:  Forms => Documentation
 * stage:  Unreviewed => Accepted


Comment:

 Yes, the documentation could state more clearly that the *instance* passed
 to the form will be modified and should not be reused later in the view,
 especially if validation fails.

-- 
Ticket URL: 
Django 
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 django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #18548: View changes field when 'unique_together' is not satisfied in a Form

2012-07-10 Thread Django
#18548: View changes field when 'unique_together' is not satisfied in a Form
---+--
 Reporter:  anonymous  |Owner:  nobody
 Type:  Bug|   Status:  reopened
Component:  Forms  |  Version:  1.3
 Severity:  Normal |   Resolution:
 Keywords: | Triage Stage:  Unreviewed
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--

Comment (by anonymous):

 I think this is a duplicate of #12896, which was ultimately "fixed" via a
 [https://docs.djangoproject.com/en/1.4/topics/forms/modelforms/#the-is-
 valid-method-and-errors documentation note]. Possibly that note needs to
 be extended to indicate that the model cleaning in-place means that part
 of the requested changes may be applied to the instance before form
 validation ultimately fails and causes `is_valid()` to return False?

-- 
Ticket URL: 
Django 
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 django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #18548: View changes field when 'unique_together' is not satisfied in a Form

2012-07-10 Thread Django
#18548: View changes field when 'unique_together' is not satisfied in a Form
---+--
 Reporter:  anonymous  |Owner:  nobody
 Type:  Bug|   Status:  reopened
Component:  Forms  |  Version:  1.3
 Severity:  Normal |   Resolution:
 Keywords: | Triage Stage:  Unreviewed
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--
Changes (by anonymous):

 * status:  closed => reopened
 * resolution:  invalid =>


Comment:

 Sorry i did edit the code to simplify it a bit but i apparently did it too
 fast. This should be more clear:

 {{{
 #!python
 def edit_person(request, person_id):

 person = get_object_or_404(Person, pk=person_id)

 print person.name

 if not request.method == 'POST':
 form = PersonForm(instance=person)

 else:
 form = PersonForm(request.POST, instance=person)

 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))
 }}}

-- 
Ticket URL: 
Django 
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 django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #18548: View changes field when 'unique_together' is not satisfied in a Form

2012-07-08 Thread Django
#18548: View changes field when 'unique_together' is not satisfied in a Form
---+--
 Reporter:  anonymous  |Owner:  nobody
 Type:  Bug|   Status:  closed
Component:  Forms  |  Version:  1.3
 Severity:  Normal |   Resolution:  invalid
 Keywords: | Triage Stage:  Unreviewed
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--
Changes (by aaugustin):

 * status:  new => closed
 * resolution:   => invalid


Comment:

 You must have edited the code before posting it. As is it will crash for
 at least two reasons:
 - the `Person` class is used both as a model and as a form,
 - the `place` variable is used but is never defined.

 The code you've posted can't work and the result you're describing sounds
 reasonable. I can't guess what your actual code looks like nor why you
 think the result isn't correct.

 In short, this appears to be a support question rather than a bug in
 Django. Please follow the instructions on this page:
 TicketClosingReasons/UseSupportChannels. Thanks!

-- 
Ticket URL: 
Django 
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 django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #18548: View changes field when 'unique_together' is not satisfied in a Form

2012-07-08 Thread Django
#18548: View changes field when 'unique_together' is not satisfied in a Form
---+--
 Reporter:  anonymous  |Owner:  nobody
 Type:  Bug|   Status:  new
Component:  Forms  |  Version:  1.3
 Severity:  Normal |   Resolution:
 Keywords: | Triage Stage:  Unreviewed
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--
Changes (by aaugustin):

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


Old description:

> 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.

New description:

 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.

--

Comment:

 Fixed formatting (please use preview).

-- 
Ticket URL: 
Django 
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 django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



[Django] #18548: View changes field when 'unique_together' is not satisfied in a Form

2012-07-01 Thread Django
#18548: View changes field when 'unique_together' is not satisfied in a Form
+
 Reporter:  anonymous   |  Owner:  nobody
 Type:  Bug | Status:  new
Component:  Forms   |Version:  1.3
 Severity:  Normal  |   Keywords:
 Triage Stage:  Unreviewed  |  Has patch:  0
Easy pickings:  0   |  UI/UX:  0
+
 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.

-- 
Ticket URL: 
Django 
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 django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.