def edit_auction_view(request,id_auction): info = "Loading..." auction = Auction.objects.get(Id=id_auction) if request.method == "POST": form = AddAuctionForm(request.POST,instance=auction) if form.is_valid(): edit_auction = form.save(commit=False) edit_auction.status = True edit_auction.save() info = "Edited successfully." return HttpResponseRedirect('/auction/%s/' % edit_auction.Id) else: form = AddAuctionForm(instance=auction) context = {'form':form,'informacion':info} return render_to_response('Auctions/editAuction.html',context,context_instance=RequestContext(request))
def add_auction_view(request): message = '' if request.method == 'POST': form = AddAuctionForm(request.POST) if form.is_valid(): add = form.save(commit=False) add.status = True add.save() message = 'Saved successfully.' return HttpResponseRedirect('/auction/%s' % add.Id) else: form = AddAuctionForm() context = {'form': form, 'message': message} return render_to_response('Auctions/addAuction.html', context, context_instance=RequestContext(request))