def addshow(request): if request.method == 'POST': s = Show(author=request.user) form = ShowForm(request.POST, instance=s) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('addepisode', args=[slugify(form.cleaned_data["name"])])) else: form = ShowForm() return render_to_response('tvshow/addshow.html', { 'form':form, 'user':request.user, })
def edit_show(request, slug): show = Show.objects.get(slug=slug) if request.method == 'POST': # formulario enviado show_form = ShowForm(request.POST, instance=show) if show_form.is_valid(): show_form.save() return HttpResponseRedirect(reverse('show_detail', args=[slug])) else: show_form = ShowForm(instance=show) return render_to_response( 'tvshow/editshow.html', {'form': show_form,}, context_instance=RequestContext(request))