--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/v0GYTeLYPAsJ.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
@login_required
def create_termin(request, calid, year=None, month=None, day=None):
kalender = get_object_or_404(Kalender,pk=int(calid))
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
form.save()
return HttpResponse(pprint.pformat(formdata) + pprint.pformat(inspect.getmembers(form['participants'])) + "\n\n" + pprint.pformat(inspect.getmembers(request.user)),mimetype="text/plain")
else:
date = datetime.date(month=int(month), day=int(day), year=int(year)) if day else None
print("viewdate",date)
form = NewTerminForm(initial={'date':date,})
return render_to_response("kalender/new_termin.html", dict(debug=1, calid=calid,form=form, ),context_instance=RequestContext(request))
Yes, it is possible:obj = form.save(commit=False)obj.in_calender-id = kalender
obj.save()
On Wed, May 30, 2012 at 2:56 PM, Schmidtchen Schleicher <spiol...@googlemail.com> wrote:
Is it possible to put missing data into the data of a form before calling form.save() ?
I want to add the calendar-id (calid/in_calendar) before saving to the model.
http://susepaste.org/23451355
I tried adding it after instantiating the form with form.in_calendar_id = kalender but it didn't work
I don't want to use hidden fields because manipulating them is easy
Maybe https://groups.google.com/forum/?fromgroups#!topic/django-users/F5yHH-G5QLM describes how to solve it but I didn't understand it.
PS: If you find very ugly code please correct me -- I'm a beginner
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/v0GYTeLYPAsJ.
To post to this group, send email to django...@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.
super(type, obj): obj must be an instance or subtype of type
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/WyKASDjYNEgJ.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.