def upload_video(request): if request.POST: form = VideoForm(request.POST, request.FILES) if form.is_valid(): video = form.save(commit=False) video.save() convert_video.delay(video.id) return HttpResponseRedirect('/') else: form = VideoForm() return render(request, 'upload_video.html', {'form': form})
def upload_video(request): if request.POST: form = VideoForm(request.POST, request.FILES) if form.is_valid(): video = form.save(commit=False) video.save() convert_video.delay(video.id) return HttpResponseRedirect('/') else: form = VideoForm() return render(request, 'upload_video.html', { 'form':form })
def post(self, request): tags = do_the_tags_magic(request.POST.get("tags", "")) request.POST["tags"] = tags form = VideoForm(request.POST, request.FILES) if form.is_valid(): obj = form.save(commit=False) obj.owner = request.user obj.save() form.save_m2m() return HttpResponseRedirect(reverse("accounts:index")) else: self.context["form"] = form return render(request, "app/upload.html", self.context)
def post(self, request): tags = do_the_tags_magic(request.POST.get('tags', '')) request.POST['tags'] = tags form = VideoForm(request.POST, request.FILES) if form.is_valid(): obj = form.save(commit=False) obj.owner = request.user obj.save() form.save_m2m() return HttpResponseRedirect(reverse('accounts:index')) else: context = {'video_upload_form': form} return render(request, 'app/upload.html', context)
def add(request): context = { 'title': 'Add Video', 'form_action': reverse('videos:add'), 'submit_label': 'Upload', } if request.method == 'POST': form = VideoForm(request.POST, request.FILES) if form.is_valid(): obj = form.save(commit=False) obj.owner = request.user obj.save() return HttpResponseRedirect(reverse('accounts:index')) else: context['form'] = form else: context['form'] = VideoForm() return render(request, 'app/video.html', context)