def video_new(request,section_id): if request.method=='POST': form=AddVideoForm(request.POST) if form.is_valid(): title=form.cleaned_data['title'] video_html_code=form.cleaned_data['video_html_code'] video_section=form.cleaned_data['video_section'] pub_date=timezone.now().date() v=Video(title=title, video_html_code=video_html_code, pub_date=pub_date, video_section=video_section) v.save() v.catch_youtube_id() v.save() return HttpResponseRedirect(reverse('videos:videos',kwargs={'section_id':section_id})) else: form=AddVideoForm() return_path=request.META.get('HTTP_REFERER','/') return render(request, 'video/blank_for_adding_video.html', {'form': form, 'return_path': return_path})