Beispiel #1
0
def createBrand(request):
    form = BrandFormm()
    context = {}
    context['form'] = form
    qs = Brand.objects.all()
    context['qs'] = qs
    if request.method == "POST":
        form = BrandFormm(request.POST)
        if form.is_valid():
            form.save()
            return redirect("createBrand")
    return render(request, "Rent/CreateBrand.html", context)
Beispiel #2
0
def BrandEdit(request, pk):
    form = Brand.objects.get(id=pk)
    form = BrandFormm(instance=form)
    context = {}
    context['form'] = form
    if request.method == "POST":
        form = Brand.objects.get(id=pk)
        form = BrandFormm(instance=form, data=request.POST)
        if form.is_valid():
            form.save()
            return redirect("createBrand")
    return render(request, "Rent/BrandEdit.html", context)