On Sun, Feb 24, 2008 at 11:02 PM, k4ml <[EMAIL PROTECTED]> wrote:
>  Get the instance:-
>  customer = Customer.objects.get(id=1)
>
>  Create form instance and pass a dict of data from customer instance:-
>  form = CustomerForm(initial=customer.__dict__) #instance of ModelForm

If you have a look at the ModelForm documentation, you'll see that its
constructor takes a keyword argument 'instance', which is an existing
object to populate initial data; under the hood, it uses a much more
robust method of fetching the data out of the model instance
(django.newforms.models.model_to_dict() if you're interested).


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

--~--~---------~--~----~------------~-------~--~----~
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