Initial form data from model - Django

Posted by alexBrand on Stack Overflow See other posts from Stack Overflow or by alexBrand
Published on 2012-05-31T16:36:27Z Indexed on 2012/05/31 16:40 UTC
Read the original article Hit count: 164

Filed under:

I am trying to create an edit form for my model. I did not use a model form because depending on the model type, there are different forms that the user can use. (For example, one of the forms has a Tinymce widget, while the other doesn't.)

Is there any way of setting the initial data of a form (not a ModelForm) using a model?

I tried the following but getting an error:

b = get_object_or_404(Business, user=request.user)
form = f(initial = b)

where f is a subclass of forms.Form

The error I am getting is AttributeError: 'Business' object has on attribute 'get'

© Stack Overflow or respective owner

Related posts about django