On Wed, 2009-03-04 at 22:17 -0800, Margie wrote:
> Here's a "book" analogy to what I am doing.  I am sending out a bunch
> of forms to the user.  Each form contains the title of a book (my
> "tile") and an input field where the user is being asked to input the
> author of the book.  When the view.py code receives the post data, for
> each form where the user has input the author, the view.py code will
> create a book object with the title from the form and the author that
> the user input.
> 
> So when I get an author, I need to identify which title it goes with.
> When I was writing the code I felt uncertain about identifying which
> title the form was for based on index. I thought that would work, but
> it seemed somehow safer to simply have it encoded in the same form.
> That way I don't have to match up indexes - instead I just ask the
> form what the title is. So that's why I sent the title as a hidden
> input.

Okay, that makes sense. So it's a different hidden value for each form
then. That was something I hadn't been sure about in these threads: at
one point it looked like it was always the same value, at other times,
it was a different value.

> 
> The reason that has_changed() was false was simply that in my
> debugging, on the client side I was not filling out the form.  I was
> just leaving it blank.  Then in view.py I was looking at the form to
> verify that I could get back the book title, and that's when I
> encountered the fact that cleaned_data was empty.

Okay. So I think you now understand why that's happening and that it's
not a bug.

I'd also guess it's not really a problem, at least in the book analogy
you give. If they don't provide an author for the book, you just don't
do anything with that title (the form won't appear to have been filled
in). That seems like fairly reasonable behaviour: only create an object
when the user supplies some data.


> 
> What can I say ... I've been trying a lot of different things to
> really get a handle on this and it's taken me down a lot of strange
> paths.

Yeah, that's understandable. Sometimes running around a problem a lot
doesn't help with keeping a perspective on which approaches are working.
That's why I'm happy to keep going with threads like this and asking
different questions, since reorienting oneself from time to time
sometimes takes an extra set of eyes.

Regards,
Malcolm



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to