May 2020
Intermediate to advanced
404 pages
10h 52m
English
In this view, we will create the bills. If a valid POST request is made to the route served by the addbill method, we create a new Bill object and save it to the database. Otherwise, we display the form for adding bills to the user. Let's see how we can do this in the following code:
def addbill(request): if request.POST: billName = request.POST['billname'] billDesc = request.POST['billdesc'] Bill = Bills.objects.create(billName=billName, user=request.user, billDesc=billDesc) Bill.save() return redirect('/') else: template = loader.get_template('add.html') context = {} context["isLogged"] = 1 return HttpResponse(template.render(context, request))
However, we still need to create the admin user before using ...
Read now
Unlock full access