This is my sort of setting .py
CMS_LANGUAGE_CONF = {
'en':['es'],
'es':['en'],
}
CMS_SITE_LANGUAGES = {
1:['en','es'],
}
CMS_LANGUAGES = (
('es', gettext('Spanish')),
('en', gettext('English')),
)
CMS_HIDE_UNTRANSLATED = True
LANGUAGES = [('es', 'Spanish'),('en', 'English')]
DEFAULT_LANGUAGE = 1
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'cms.middleware.page.CurrentPageMiddleware',
'cms.middleware.user.CurrentUserMiddleware',
'cms.middleware.toolbar.ToolbarMiddleware',
# 'django.middleware.locale.LocaleMiddleware',
'cms.middleware.multilingual.MultilingualURLMiddleware',
# 'vclubcms.middleware.URLMiddlewares.CustomMultilingualURLMiddleware'
)
My problem is :
when i access myserver:8000/myview it renders.
when i access myserver:8000/cmspage it renders
on the cms page templage i have some links . which get converted to /language_code/cmspage due to multilingual. so when click on link it is not opening .
e.g. myserver:8000/language_code/cmspage not working
What i tried i followed this link
http://ilian.i-n-i.org/language-redirects-for-multilingual-sites-with-django-cms/comment-page-1/
and enable the
'vclubcms.middleware.URLMiddlewares.CustomMultilingualURLMiddleware'
and then i run the myserver:8000/language_code/cmspage
it shows
The page isn't redirecting properly
and with 21 request.
Please suggest how can i solve this problem .
Related
I read Django tutorial but found nothing related to never expiring session.
Requirement - User should logged out only if he/she initiate by clicking on logout.
How can I solve this issue?
My django project settings related to session -
INSTALLED_APPS = (
..
'django.contrib.sessions',
..
)
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication',
'rest_framework.authentication.BasicAuthentication',
#'rest_framework.authentication.SessionAuthentication',
)
}
MIDDLEWARE_CLASSES = (
'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',
)
AUTHENTICATION_BACKENDS = (
"django.contrib.auth.backends.ModelBackend",
"allauth.account.auth_backends.AuthenticationBackend",
)
By default Django keeps sessions between browser closes. You can modify this behavior with the SESSION_EXPIRE_AT_BROWSER_CLOSE setting.
https://docs.djangoproject.com/en/1.8/topics/http/sessions/#browser-length-vs-persistent-sessions
I am using django 1.6.4 and django toolbar version django-debug-toolbar==1.2.
I do get the toolbar on the side but when I click on any of the menu items, it shows me the html elements from my home page within the toolbar overlay. I have done collectstatic after installing django toolbar. HTML generated is not valid but issue seems to be from the css and scripts tag from django toolbar.
Any help will be much appreciated.
Thanks
Updated:
urls.py entry
if settings.DEBUG:
import debug_toolbar
urlpatterns += patterns('',
url(r'^__debug__/', include(debug_toolbar.urls)),
)
settings.py
DEBUG = True
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware',
)
THIRD_PARTY_APPS = (
'suit',
'debug_toolbar',
'south',
'crispy_forms',
'haystack',
'taggit',
)
MIDDLEWARE_CLASSES = (
'django.middleware.gzip.GZipMiddleware',
'htmlmin.middleware.HtmlMinifyMiddleware',
'django.middleware.http.ConditionalGetMiddleware',
'johnny.middleware.LocalStoreClearMiddleware',
'johnny.middleware.QueryCacheMiddleware',
'announce.middleware.AnnounceCookieMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.transaction.TransactionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'giaola.middleware.ForceDefaultLanguageMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'mediagenerator.middleware.MediaMiddleware',
'django.contrib.redirects.middleware.RedirectFallbackMiddleware',
'minidetector.Middleware',
# Uncomment the next line for simple clickjacking protection:
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'breadcrumbs.middleware.BreadcrumbsMiddleware',
'achievements.middleware.AutoAchievementChecker',
)
These are all my middleware and I'm not entirely sure they're in the correct order.
I have my doubts about GZip and HTMLmin being at the top with caching following after them but middleware has always been my weakpoint in Django.
"ForceDefaultLanguageMiddleware" is just to enforce the language, like so:
def process_request(self, request):
if request.META.has_key('HTTP_ACCEPT_LANGUAGE'):
del request.META['HTTP_ACCEPT_LANGUAGE']
Any input would be more than appreciated.
I have a multilanguage site (it, en, ru) that use django-cms with some apps hooked on various page. my problem is that the content is always served in italian, even if i visit pages with '/en/' or '/ru/' as prefix.
On my base template (base.html) i have a {{ lang }} template variable that allow me to retrieve current page languages, and it worked fine...till today. Now if i visit wwww.myhomepage/en (or /ru), the value of 'lang' is always 'it'.
These are mine languages settings (cms and not cms) and also other settings related with languages:
LANGUAGE_CODE = 'it'
DEFAULT_LANGUAGE = 0
LANGUAGES = (
('it', gettext(u'Italiano')),
('en', gettext(u'English')),
('ru', gettext(u'Russian')), )
CMS_LANGUAGES = (
('it', ugettext('Italian')),
('en', ugettext('English')),
('ru', ugettext('Russian')),
)
LOCALE_PATHS = (os.path.join(PROJECT_PATH, 'locale'))
CMS_LANGUAGE_CONF = {
'it': ['en'],
'ru': ['en'],
}
CMS_HIDE_UNTRANSLATED = False
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'cms.middleware.multilingual.MultilingualURLMiddleware',
'cms.middleware.page.CurrentPageMiddleware',
'cms.middleware.user.CurrentUserMiddleware',
'cms.middleware.toolbar.ToolbarMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'cms.middleware.multilingual.MultilingualURLMiddleware',
'cms.middleware.page.CurrentPageMiddleware',
'cms.middleware.user.CurrentUserMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware',
'cms.middleware.multilingual.MultilingualURLMiddleware',
'cms.middleware.page.CurrentPageMiddleware',
'cms.middleware.user.CurrentUserMiddleware',
'cms.middleware.toolbar.ToolbarMiddleware'
)
ANY help?
Thanx
You have several middleware that repeated inside your settings. They should look something like this:
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'cms.middleware.multilingual.MultilingualURLMiddleware',
'cms.middleware.page.CurrentPageMiddleware',
'cms.middleware.user.CurrentUserMiddleware',
'cms.middleware.toolbar.ToolbarMiddleware',
)
Plus, can you give your CONTEXT_PROCESSOR settings as well?
Then, I assumed you are using Django-cms <= 2.3.5. Is this right? There is a 2.4 beta that is getting rid of MultilingualMiddleware, if you can try if it fits to you (even though it is a beta still).
It worked great before.
And now when I'm trying to go to /admin/ I have a mistake:
Module "django.contrib.auth.context_processors" does not define a "csrf" callable request processor
I read this: http://docs.djangoproject.com/en/dev/ref/contrib/csrf/
Now in my settings are:
MIDDLEWARE_CLASSES = (
'django.middleware.csrf.CsrfMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.csrf.CsrfResponseMiddleware',
)
What I have to do to make it work?
To make it work I had to write it in different order:
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)