Thursday, May 31, 2012

Re: Adding values to formdata of ModelForm before saving

On 31 mai, 20:09, Schmidtchen Schleicher <spiolli...@googlemail.com>
wrote:
> Thank you for your quick answer, but it doesn't really work. It raises the
> exception "can't assign to operator"
> My view now looks like this:
>
> @login_required
> > def create_termin(request, calid, year=None, month=None, day=None):
> >     kalender = get_object_or_404(Kalender,pk=int(calid))

You don't need the int conversion here

> >     if request.method == "POST":
> >         print(request.POST)
> >         form = NewTerminForm(request.POST)
>
> >         if form.is_valid():
> >             formdata = form.cleaned_data
> >             if formdata['participants']:
> >                 form.participants = request.user.id
> >             form.save(commit=False)
> >             form.in_calendar-id = kalender

"in_calendar-id" is not a valid Python identifier. It's parsed as
"form.in_calendar - id = kalender"

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

No comments:

Post a Comment