Last active
November 28, 2019 22:24
-
-
Save aballah-chamakh/415442cc0691a5389dbef475cd9eff57 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.shortcuts import render | |
from .models import Inference | |
from .forms import InferenceForm | |
def inference_detail_view(request,id): | |
product_obj = Inference.objects.get(id=id) | |
context = {'inference_obj':product_obj} | |
return render(request,'inference_detail.html',context) | |
def inference_list_view(request,id): | |
inference_qs = Inference.objects.all() | |
context = {'inference_object':inference_qs} | |
return render(request,'inference_list.html',context) | |
def inference_create_view(request): | |
form = InferenceForm(request.POST or None , request.FILES or None) | |
if form.is_valid(): | |
form.save() | |
return redirect('/') | |
context = {'form': form} | |
return render(request, "inference_create.html", context) | |
def inference_update_view(request,id): | |
inference_obj = Inference.objects.get(id=id) | |
form = InferenceForm(request.POST or None,request.FILES or None,instance=inference_obj) | |
if form.is_valid() : | |
form.save() | |
return redirect('/') | |
context = {'form':form} | |
return render(request,"inference_update.html",context) | |
def inference_delete_view(request,id): | |
inference_obj = Inference.objects.get(id=id) | |
if request.methode == 'POST' : | |
inference_obj.delete() | |
return redirect('/') | |
context = {'inference_obj':inference_obj} | |
return render(request,'inference_delete.html',context) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment