Hi Brock,

Yes, that's the intended behavior, and you can see the same behavior on a
regular form, without using formsets, which might make it a little more
clear what's going on:

class MyForm(forms.Form):
    name = forms.CharField()

form = MyForm(initial={'name': 'test'})
form.initial  #yields {'name':'test'}
form['name'].initial #yields 'test'
form.fields['name'].initial #yields None

The field itself is shared between all instances of MyForm, so passing in
initial data to one instance of MyForm shouldn't modify the field. Instead,
the BoundField is used to hold the data for a particular form, and as you
mention, as the initial value on the boundfield has that value you expect.

Hope this helps,
Collin


On Wed, May 23, 2018 at 2:04 PM, Brock Hallenbeck <bhallenbeck...@gmail.com>
wrote:

> When creating a formset using modelformset_factory and passing in a list
> of dictionaries to use as initial values, those values can be retrieved
> from the relevant form, and the relevant boundfield on that form.
> However the formfield class itself has no knowledge of that initial data.
>
> Is this intended behavior? I feel like I should be able to catch that
> initial value in my formfield subclasses.
>
> Here is a dpaste illustrating what I am talking about:
>
> https://dpaste.de/As6Z
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-developers+unsubscr...@googlegroups.com.
> To post to this group, send email to django-developers@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-developers.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-developers/1d84a32c-d70a-4d42-8b94-
> ca19f27ede0e%40googlegroups.com
> <https://groups.google.com/d/msgid/django-developers/1d84a32c-d70a-4d42-8b94-ca19f27ede0e%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAFO84S7n32FSzz-2JDf3BYVJTc5RdkyzO2%3Dv9YNbCEpnj-9g_g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to