Basket is behaving funny for anonymous users

35 views
Skip to first unread message

Kristof Raymas

unread,
Sep 20, 2018, 4:54:32 AM9/20/18
to django-oscar
Hi everyone,

I'm using Oscar 1.5 with Django 1.11 and Python 3.6.

By chance I noticed that for anonymous (i.e. not logged in) users the basket in my shop at times behaves funny. You can find the shop here.

I updated the project to oscar 1.5 recently, and I'm inclined to say that this behaviour could not be observed prior to the update.

Steps to reproduce:

1. Add a couple of items to the basket.
2. Eventually view the content of the basket. All the items should be there.
3. Continue adding items to the basket.
4. View the basket again. The items added after viewing the basket for the first time do not appear.
5. Click one of the grey refresh buttons, and all the items should appear.

I have not been able to reliably reproduce it following these steps myself, but in > 75% of the cases, the described behaviour can be observed.

A second, possibly related error occurs when deleting an item from the basket. Oscar throws a

RelatedObjectDoesNotExist
Line has no basket.

error here: 

oscar/apps/basket/forms.py in check_max_allowed_quantity at line 36

is_allowed, reason = self.instance.basket.is_quantity_allowed(qty_delta)

When the user is not logged in, a oscar_open_basket cookie is set, which is not the case when a user is logged in.

This is about all the information I can provide. Any thoughts?

Kristof Raymas

unread,
Sep 20, 2018, 6:39:14 AM9/20/18
to django-oscar
Never mind, I found the mistake myself.

This project has a bit of a wild setup, with Oscar being embedded in djangoCMS. 

The reason for the weird behaviour of the Oscar basket was that the djangoCMS caching policies were applied to the BasektView.

I added a @method_decorator(never_cache) to its get method, and now all is well.

Damjan Stefanovski

unread,
Sep 20, 2018, 4:50:57 PM9/20/18
to django...@googlegroups.com
Good finding, 
And the site looks great as well . 

--
https://github.com/django-oscar/django-oscar
http://django-oscar.readthedocs.org/en/latest/
https://twitter.com/django_oscar
---
You received this message because you are subscribed to the Google Groups "django-oscar" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-oscar...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-oscar.
To view this discussion on the web, visit https://groups.google.com/d/msgid/django-oscar/f673ebcd-120a-4a5c-883b-1bbacadde149%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages