Ejemplo n.º 1
0
 def post(self, request, *args, **kwargs):
     form = Customerform(request.POST, request.FILES)
     if form.is_valid():
         form.save()
         return redirect('customerlist')
     else:
         return redirect('customercreate')
Ejemplo n.º 2
0
 def post(self, request, *args, **kwargs):
     id = kwargs.get("pk")
     qs = self.model.objects.get(id=id)
     form = Customerform(instance=qs, data=request.POST, files=request.FILES)
     if form.is_valid():
         form.save()
         return redirect('customerlist')
     else:
         return render(request, self.template_name, self.context)
Ejemplo n.º 3
0
class Customerdelete(DeleteView):
    model = Customerprofile
    template_name = "Customer/customerdelete.html"
    form_class = Customerform()
    context = {}

    def get(self, request, *args, **kwargs):
        id = kwargs.get("pk")
        qs = self.model.objects.get(id=id)
        self.context['form'] = Customerform(instance=qs)
        return render(request, self.template_name, self.context)

    def post(self, request, *args, **kwargs):
        id = kwargs.get("pk")
        qs = self.model.objects.get(id=id)
        qs.delete()
        return redirect('customerlist')      
Ejemplo n.º 4
0
class Customercreate(CreateView):
    model = Customerprofile
    form_class = Customerform()
    template_name = "Customer/customercreate.html"
    context = {}

    def get(self, request, *args, **kwargs):
        self.context['form'] = self.form_class
        return render(request, self.template_name, self.context)

    def post(self, request, *args, **kwargs):
        form = Customerform(request.POST, request.FILES)
        if form.is_valid():
            form.save()
            return redirect('customerlist')
        else:
            return redirect('customercreate')
Ejemplo n.º 5
0
class Customeredit(TemplateView):
    model = Customerprofile
    form_class = Customerform()
    template_name = "Customer/customeredit.html"
    context = {}

    def get(self, request, *args, **kwargs):
        id = kwargs.get('pk')
        qs = self.model.objects.get(id=id)
        form = Customerform(instance=qs)
        self.context['form'] = form
        return render(request, self.template_name, self.context)

    def post(self, request, *args, **kwargs):
        id = kwargs.get("pk")
        qs = self.model.objects.get(id=id)
        form = Customerform(instance=qs, data=request.POST, files=request.FILES)
        if form.is_valid():
            form.save()
            return redirect('customerlist')
        else:
            return render(request, self.template_name, self.context)
Ejemplo n.º 6
0
 def get(self, request, *args, **kwargs):
     id = kwargs.get('pk')
     qs = self.model.objects.get(id=id)
     form = Customerform(instance=qs)
     self.context['form'] = form
     return render(request, self.template_name, self.context)