Hello,

I'm confused: why does BoundField.as_widget retrieve initial data with
self.name (without prefix):

>>>    def as_widget(self, widget=None, attrs=None):
...
>>>        if not self.form.is_bound:
>>>            data = self.form.initial.get(self.name, self.field.initial)

But if there is data (form is bound), the "html_name" is used (which
includes the prefix):

>>>    def _data(self):
>>>        """
>>>        Returns the data for this BoundField, or None if it wasn't given.
>>>        """
>>>        return self.field.widget.value_from_datadict(self.form.data, 
>>> self.form.files, self.html_name)

I've got a big data grid with lots of copies of a form; I was passing
the same initial data to all in a big dictionary with prefixes --
which doesn't work; but I have another purpose for this same
dictionary:

I don't want to try to save rows that aren't changed, so I was putting
the dictionary in the session to check for changes on post (poor man's
locking: then I check db w/ select for update to see if anyone else
changed the changed rows....).

It looks (grumble) that I have to reformat the data for these two
purposes... but if there is a reason for it, I'll put up with it, of
course :).

Best for me would be that BoundField.as_widget used html_name, but can
someone tell me why it doesn't?

Most gratefully,
- Shaun Cutts


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to