def createBuySell(request): if request.method != 'POST': pform = PublicationForm() bform = BuySellForm() else: pform = PublicationForm(request.POST) bform = BuySellForm(request.POST) if pform.is_valid() and bform.is_valid(): saveBuySell(bform, pform, request.user) return HttpResponseRedirect('/publications/buysell') return render(request, 'publications/buysell_create.html', {'pform':pform, 'bform':bform})
def EditBuySell(request, buysellID): publication = get_object_or_404(Publication, pk=buysellID) if publication.author.user != request.user: return HttpResponseForbidden() buysell= publication.buysell if request.method != 'POST': pform = PublicationForm(instance=publication) bform = BuySellForm(instance=buysell) else: pform = PublicationForm(request.POST, instance = publication) bform = BuySellForm(request.POST, instance =buysell) if pform.is_valid() and bform.is_valid(): saveBuySell(bform, pform, request.user) return HttpResponseRedirect('/publications/buysell') return render(request, 'publications/buysell_create.html', {'pform':pform, 'bform':bform})