webforms - Django set data from db into field -
i trying fill 2 <input type="text">
fields value database, default django forms.
i tried set query, gets value when starts , won't take db after values changed id db.
my forms looks like:
s_size = forms.integerfield(initial=sizes.objects.get(id=1).small) m_size = forms.integerfield(initial=sizes.objects.get(id=1).medium)
any appreciated.
you should pass in initial data view, described in documentation:
class myform(forms.form): s_size = forms.integerfield(i) m_size = forms.integerfield()
...
def my_view(request): s_size_value = sizes.objects.get(id=1).small m_size_value = sizes.objects.get(id=1).medium form = myform(initial={'s_size': s_size_value, 'm_size': m_size_value})
Comments
Post a Comment