我一直在使用django框架背面的Python構建的商店,一切正常,直到我注意到當用戶進行結帳並被請求登錄時在他們這樣做和他們的籃子倒空...明顯這對籃子來說並不是一件好事,我想知道是什麼造成了這種情況,是否可以查看一下我的代碼並給出一些建議?我不知道該怎麼做。用戶登錄時丟失會話數據
=====編輯 - 下面是我的代碼,我將不勝感激,如果有人可以給我的,我怎麼能阻止籃下清算一擊,當用戶登錄=====
def basket(request):
"""
Display the current state of the basket and allow the customer to modify
the discount and quantities of each row of the basket
"""
data = {}
basket = Basket(request)
discount_form = DiscountCodeForm(basket)
if request.method == "POST":
if 'update' in request.POST:
basket.post_update(request)
discount_form = DiscountCodeForm(basket, request.POST)
if discount_form.is_valid():
cleaned_data = discount_form.cleaned_data
if cleaned_data['discount_code']:
basket.set_discount(Offer.objects.get(code=cleaned_data['discount_code']))
if 'delete' in request.POST:
basket.post_delete(request)
if 'remove_discount' in request.POST:
basket.remove_discount()
data['discount_form'] = discount_form
data['logged_in'] = persistent_account(request)
data['pageclass'] = 'basket'
data['category'] = Category.objects.root_category()
data['products'] = Product.objects.all()
data['regions'] = Zone.objects.all()
data['currency'] = Currency.get_default_currency()
return render_to_response('basket.html', data, RequestContext(request))
def login(request):
"""
Log the user in.
The form is where the actual login occurs. If already logged in, then
forward to the last attempted page, or, if came directly to the login page,
the account page.
@todo: Incorrect guesses limit of 10 then deactive account
"""
data = {}
redirect_to = request.GET.get('next', reverse('account'))
account = persistent_account(request)
if account:
return HttpResponseRedirect(reverse('account'))
if request.method == "POST":
login_form = LoginForm(request, request.POST)
# This next line will also cause a login
if login_form.is_valid():
login_form.user.message_set.create(message="You have successfully logged in. Welcome back.")
return HttpResponseRedirect(redirect_to)
else:
login_form = LoginForm(request)
data['shop_login_form'] = login_form
data['pageclass'] = 'customer_login'
return render_to_response('login.html', data, RequestContext(request))
我給你的是我的登錄視圖和籃子視圖,如果不是隨意喊我,那麼這個視圖就足夠了。
您沒有發佈任何代碼... – 2009-11-24 19:20:08
您是否正在使用自定義構建的購物車?的Satchmo?還有別的嗎?你是否縮小了問題的根源?你在問什麼? 「來看看我的代碼!」是諮詢顧問的要求,諮詢費用。 「爲什麼這段代碼做錯了什麼?」是一個公平的問題,通常可以在這樣的問題板上處理。 – jcdyer 2009-11-24 20:15:39
與jcd一致......我們需要更多詳細信息,例如它正在做什麼,正在打印的任何錯誤以及您可以提供的任何調試信息。如果它自己的代碼嘗試打印正在傳遞給檢出的輸出,並查看是否有任何事情是痛苦的並導致數據消失。 – 2009-11-24 20:17:54