def create(self, request): kwargs = request.POST.copy() kwargs.update({ 'profile': request.user.get_profile().pk }) form = URLCallbackForm(kwargs) if not form.is_valid(): raise FormValidationError(form) return form.save()
def update(self, request, callback_id=None): profile = request.user.get_profile() callback = profile.urlcallback_set.get(pk=callback_id) kwargs = request.POST.copy() kwargs.update({ 'profile': profile.pk }) form = URLCallbackForm(kwargs, instance=callback) if not form.is_valid(): raise FormValidationError(form) return form.save()