Esempio n. 1
0
def restaurant_account(request):
    user_form = UserFormForEdit(instance= request.user)
    restaurant_form = RestaurantForm(instance = request.user.restaurant)
    if request.method == "POST":
        user_form = UserFormForEdit(request.POST, instance = request.user)
        restaurant_form = RestaurantForm(request.POST, request.FILES, instance = request.user.restaurant)
        if user_form.is_valid() and restaurant_form.is_valid():
            user_form.save()
            restaurant_form.save()
    return render(request, 'restaurant/account.html', {
        "user_form": user_form,
        "restaurant_form": restaurant_form
    })
Esempio n. 2
0
def restaurant_account(request):
    user_form = UserFormForEdit(instance=request.user)
    restaurant_form = RestaurantForm(instance=request.user.restaurant)

    if request.method == "POST":  #This executes when the Save button is pressed to update Account details
        user_form = UserFormForEdit(request.POST, instance=request.user)
        restaurant_form = RestaurantForm(request.POST,
                                         request.FILES,
                                         instance=request.user.restaurant)

        if user_form.is_valid() and restaurant_form.is_valid(
        ):  #check forms validity
            user_form.save()  #save form
            restaurant_form.save()  #save form

    return render(request, 'restaurant/account.html', {
        "user_form": user_form,
        "restaurant_form": restaurant_form
    })  #after successful login it renders the account.html