Sunday, September 1, 2013

Passing initial values to a form

Hi

I have gotten myself badly confused today trying to figure this out.

If I have these elements

# urls.py
url(r'^banker/(?P<iid>\d+)/iac$', view = IacCreateView.as_view())

# views.py
class IacCreateView(LoginRequiredMixin, CreateView):
template_name = 'iaccount_form.html'
model = Iaccount
form_class = IaccountForm

# forms.py
class IaccountForm(forms.ModelForm):
class Meta(object):
model = Iaccount

How can I use a value (iid) from the url to set a field's initial
value in the form

or more generally pass initial values into the form from a previous page
--
Drew

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment