On Monday, February 14, 2011 1:59:08 PM UTC, Szabo, Patrick (LNG-VIE) wrote:
>
> <snip> 
>
Now i did exclude certain fields in my form because i have to set them 
> automaticaly.
> Eg. I have a field that's called Mitarbeiter. I want to set the field to 
> the current user id so i've tried this:
>
> def main(request):
>     f = BuchungForm(request.POST)
>     buchung = f.save(commit=False)
>     buchung.Mitarbeiter = 'request.user.id'
>     buchung.save()    
>     return render_to_response('main/index.html', {'user' : request.user, 
> 'form' : f})
>
> but this gives me the following error:
>
> could not be created because the data didn't validate.
>
> It seems like as soon as i enter the site it tries co submit the data. Can 
> i somehow stop that from hapening. ?!
>
Yes, by following the documentation that Tom has now linked to twice.  For 
absolute clarity, let me link you to the actual bit again:
http://docs.djangoproject.com/en/1.2/topics/forms/#using-a-form-in-a-view
This shows you exactly how to do it. Please follow it.
--
DR.

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