Hello,

We are running Django 1.5.1 with some ajax on the front end 
(http://goo.gl/RuofnO) that allows visitors to add certain pages to their 
favorites list (similar in functionality to a shopping cart). The 'Save to 
Favorites' does not seem to function correctly when the cache middleware's 
are enabled:

 'django.middleware.cache.UpdateCacheMiddleware',
 'django.middleware.cache.FetchFromCacheMiddleware',

If I leave the above middleware's disabled, the ajax 'Save to Favorites" 
works successfully;

However when caching middlewares are enabled, it may allow you to add one 
property to the list, but after you will still get 'Favorite Added' message 
upon clicking 'Save to Favorites' but upon viewing the list you find 
nothing was added to the list.

I tried applying never cache to the view responsible for the ajax response 
in attempt exclude this part
of the page from cache, but this did not seem to help any.

#from django.views.decorators.cache import never_cache
>
>  
>
#@never_cache
> def build_favorites(session_favorites):
>     listing  = ListingAPI()
>     favorites = []
>     for prop_type, _id, beds in session_favorites:
>         if prop_type == 'robo':
>             obj = Property.objects.get(id=_id)
>             if beds == '1':
>                 price = obj.one_bed_price
>             elif beds == '2':
>                 price = obj.two_bed_price
>             elif beds == '3':
>                 price = obj.three_bed_price
>         else:
>             obj = listing.get(_id).get('listing', {})
>             price = obj.get('price','USD')
>
>         favorites.append((prop_type, obj, beds, price))
>
>     return favorites
>


Does anyone have any ideas on why the 'Save to Favorites' functionality 
breaks when caching is enabled?

Thanks!

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2539ea56-0f7e-4207-97cf-53ebfdcef6d5%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to