form.save(request) -> form.save(request, kalender)
On Thu, May 31, 2012 at 8:47 PM, Kurtis Mullins <kurtis.mullins@gmail.com> wrote:
Hey,
I tried re-writing your view and form for you -- but I ran into a snag. I don't read German so other than code-wise (and a couple of obvious words, like kalender and participants) I'm not really sure what you're trying to accomplish.
I do see one obvious issue, though. Participants is a many-to-many field in your Model and you're also using the same attribute in your form. Here's something you could try in your form and view:
View:
--------
if request.method == 'POST':
form = MyForm(request.POST)
if form.is_valid():
form.save(request)
Form:
---------
def save(self, request, kalender, commit=True):
# Get an Instance of the Termin object.
obj = super(Termin, self).save(commit=True)
# Add the user as a participant if 'add_me' = True
if self.cleaned_data['add_me']:
obj.participants.add(request.user)
# Set the Calendar, Save, and return
obj.in_calendar = kalender
obj.save()
return obj
Hopefully I didn't just confuse you more :) Good luck!
--
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