Sunday, November 6, 2016

Re: Need help to catch "cart_id" based on session.

I would try request.session.get('cart_id', None) instead of
request.session['card_id'].

Both act the same if the key exist in the dict. When the key is
missing, the first return the second value (None in this case) while
the second raise a Key Error exception.

2016-11-05 13:10 GMT+01:00 Shazia Nusrat <shazianusra@gmail.com>:
> Hi,
>
> I am using doorsale repo for building ecommerce site due to it's simplicity
> but I am stuck at the error while trying to catch cart session ID.
>
> The repo link is:
>
> https://github.com/mysteryjeans/doorsale
>
> Error traceback is below:
>
>
> Request Method: POST
> Request URL: http://localhost:8000/sales/checkout/order/
>
> Django Version: 1.9.11
> Python Version: 2.7.12
> Installed Applications:
> ('django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.sites',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> 'doorsale',
> 'doorsale.geo',
> 'doorsale.pages',
> 'doorsale.accounts',
> 'doorsale.catalog',
> 'doorsale.sales',
> 'doorsale.financial',
> 'doorsale.payments',
> 'sorl.thumbnail',
> 'pipeline')
> Installed Middleware:
> ('django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> 'django.middleware.clickjacking.XFrameOptionsMiddleware')
>
>
>
> Traceback:
>
> File
> "/home/osboxes/Desktop/doorsaleproj/local/lib/python2.7/site-packages/django/core/handlers/base.py"
> in get_response
> 149. response =
> self.process_exception_by_middleware(e, request)
>
> File
> "/home/osboxes/Desktop/doorsaleproj/local/lib/python2.7/site-packages/django/core/handlers/base.py"
> in get_response
> 147. response = wrapped_callback(request,
> *callback_args, **callback_kwargs)
>
> File
> "/home/osboxes/Desktop/doorsaleproj/local/lib/python2.7/site-packages/django/utils/decorators.py"
> in inner
> 184. return func(*args, **kwargs)
>
> File
> "/home/osboxes/Desktop/doorsaleproj/local/lib/python2.7/site-packages/django/views/generic/base.py"
> in view
> 68. return self.dispatch(request, *args, **kwargs)
>
> File
> "/home/osboxes/Desktop/doorsaleproj/local/lib/python2.7/site-packages/django/views/generic/base.py"
> in dispatch
> 88. return handler(request, *args, **kwargs)
>
> File
> "/home/osboxes/Desktop/doorsaleproj/local/lib/python2.7/site-packages/doorsale/sales/views.py"
> in post
> 351. cart_id = request.session['cart_id']
>
> File
> "/home/osboxes/Desktop/doorsaleproj/local/lib/python2.7/site-packages/django/contrib/sessions/backends/base.py"
> in __getitem__
> 50. return self._session[key]
>
> Exception Type: KeyError
>
> Please advice.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscribe@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAD83tOzsSY%3D%2BkW6bSTWfR2ea17JgOOy%3DVNWunLR6P%3DxJDF9xRQ%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.



--

Cordialement, Coues Ludovic
+336 148 743 42

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEuG%2BTY_K4ULw%3DFLT_4nPMSt299C7%3D8VGAeVr_DsTo-FnFEFpA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment