Skip to content

Instantly share code, notes, and snippets.

@TarasTarasTaras
Created January 24, 2016 13:12
Show Gist options
  • Save TarasTarasTaras/ca288ab666c1db1aee7c to your computer and use it in GitHub Desktop.
Save TarasTarasTaras/ca288ab666c1db1aee7c to your computer and use it in GitHub Desktop.
def add_serie(request):
context = {
'serie_form': AddSerieForm()
}
if request.POST and request.user.is_authenticated():
add_serie_form = AddSerieForm(request.POST)
if add_serie_form.is_valid():
serie = add_serie_form.save(commit=False)
serie[creator] = request.user.guidauser
serie.save()
add_serie_form.save()
return redirect(reverse('main:serie', kwargs={'serie_id': serie.id}))
else:
context['serie_form'] = add_serie_form
return render(request, 'serie/add_serie.html', context)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment