Hi,

if you use ModelForm, the data from the database are the initial
form data.

If you create a new record with ModelForm, you could use the "initial"
parameter to supply some default values. More can be found in the docs.

  Thomas

Magnus Valle schrieb:
> Short:
> How do I populate a form with data from the database?
> Fx. if I want to let users edit the data they have entered.
> 
> Long:
> Currently, I have a form where the user(if logged in) will enter data 
> and when it is submitted some extra data is entered to the form before 
> it is saved, a time-stamp and the request.user .
> 
> But is there a way to open the form, looking to see if the user already 
> has entered some data, then populate the form with that data. But if the 
> user does not have a entry in the database, then presenting an empty form. ?


-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de

--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to