졔졔류류
80
2019-10-11 17:21:24
1
987

Django didn't return an HttpResponse object


from django.shortcuts import render
from order.models import OrderItem, Order
from product.models import Product
from accounts.models import User
from order.forms import OrderCreateForm
from cart.cart import Cart

def order_create(request):
cart = Cart(request)
if request.method == 'POST':
form = OrderCreateForm(request.POST)
if form.is_valid():
profile = User.objects.get(user=request.user)
form.instance.user = request.user
order = form.save()
profile.address = request.POST.get('address')
profile.save()
for item in cart:
OrderItem.objects.create(
order = order,
user = request.user,
product = item['product'],
price = item['price'],
quantity = item['quantity'],
)
products = Product.objects.get(p_name=item['product'])
products.p_stock -= item['quantity']
products.order_q += item['quantity']
products.save()

userinfo = User.objects.get(user=request.user)
userinfo.point = userinfo.point + products.p_point * item['quantity'] - order.usepoint
userinfo.save()

cart.clear()

return render(request, 'order/order_created.html', {'order': order})

else:
form = OrderCreateForm()
context = {
'form': form,
'cart': cart,
}
return render(request, 'order/order_create.html', context=context)
라고 입력을 했는데, The view order.views.order_create didn't return an HttpResponse object. It returned None instead.
오류가 뜹니다. 어떻게 해야될까요...........

0
0
  • 답변 1

  • 뒷집할머니
    1k
    2019-10-11 17:33:43

    GET method 부터 에러나면 template path 잘 잡혔는지 확인해 보세요.

    0
  • 로그인을 하시면 답변을 등록할 수 있습니다.