django-mobile icon indicating copy to clipboard operation
django-mobile copied to clipboard

some time lost without FLAVOURS_GET_PARAMETER

Open BergSoft opened this issue 9 years ago • 7 comments

BergSoft avatar Apr 08 '15 13:04 BergSoft

Hi, it is intended that the flavour is not set permanently if you don't do so explicitly with the GET paramter. The reason is that you don't lock in users into one flavour forever, but allow to adjust the target with a custom MobileDetectionMiddleware when you go along.

In which cases did you have trouble when the flavour was not set permanently?

gregmuellegger avatar Apr 09 '15 12:04 gregmuellegger

flavour was set permanently via GET parameter but after goto link on this page flavour lost. P.S. Sorry for my English.

shtalinberg avatar May 07 '15 09:05 shtalinberg

@shtalinberg Hi, sorry I don't exactly understand in which cases it is breaking for you. Can you give an example of URLs that is triggering the problem and your settings.MIDDLEWARE_CLASSES setting?

An example of URLs would be:

http://localhost:8000/articles/post/ # shows full flavour
http://localhost:8000/articles/post/?flavour=mobile # shows mobile flavour
http://localhost:8000/articles/post/ # shows full flavour again, but should show mobile

gregmuellegger avatar May 07 '15 10:05 gregmuellegger

yes - the problem is as you have described in example

my MIDDLEWARE_CLASSES = ( 'corsheaders.middleware.CorsMiddleware', 'subdomains.middleware.SubdomainURLRoutingMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', ......... my apps 'django.contrib.messages.middleware.MessageMiddleware', 'django_mobile.middleware.MobileDetectionMiddleware', 'django_mobile.middleware.SetFlavourMiddleware', ......... my apps 'django.middleware.clickjacking.XFrameOptionsMiddleware', )

shtalinberg avatar May 07 '15 12:05 shtalinberg

@shtalinberg Ok that looks correct. You need to have cookies enabled to make that work. Please check if you have a cookie with the name flavour set after you have set the flavour with ?flavour=mobile.

gregmuellegger avatar May 07 '15 13:05 gregmuellegger

yes, I have cookies enabled. but we use session backend #django-mobile FLAVOURS_GET_PARAMETER = 'setmode' FLAVOURS = ('full', 'mobile') DEFAULT_MOBILE_FLAVOUR = "mobile" FLAVOURS_COOKIE_KEY = 'setmode' FLAVOURS_STORAGE_BACKEND = 'session' # Available values: 'session' and 'cookie'.

shtalinberg avatar May 07 '15 21:05 shtalinberg

Hm ok, that looks good so far. Can you somehow check that the 'flavour' key is set in your session after you have visited a site with the ?flavour=... GET parameter?

gregmuellegger avatar May 08 '15 12:05 gregmuellegger