Django,Logout_URL不会很好地重定向 [英] Django, Logout_URL doesn't redirect well

查看:131
本文介绍了Django,Logout_URL不会很好地重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置了LOGOUT_URL ='http://www.google.fr,但是当我注销时,它仍然转到默认的url'/ accounts / logout /'以及其他URL重定向。
我已经找到了所有地方,我真的不知道为什么它不工作

 #Django设置为临床项目。 

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS =(
('admin','admin@fr.fr'),


MANAGERS = ADMINS


LOGOUT_URL ='http://www.google.fr'

DATABASES = {
'default':{
'ENGINE':'django.db.backends.sqlite3',#添加'postgresql_psycopg2','mysql','sqlite3'或'oracle'。
'NAME':r'C:\Users\Megapayo\Desktop\Laurent_practica\pruebasdjango\proyecto\clinica\sqlite.db',#或使用sqlite3的数据库文件路径。
'USER':'',#不与sqlite3一起使用。
'PASSWORD':'',#不与sqlite3一起使用。
'HOST':'',#设置为localhost的空字符串。不适用于sqlite3。
'PORT':'',#设置为空字符串为默认值。不适用于sqlite3。
}
}

#此安装的本地时区。可以在这里找到选择:
#http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
#虽然并不是所有的操作系​​统都可以选择所有选项。
#在Unix系统上,值为None将导致Django与操作系统使用相同的
#timezone。
#如果在Windows环境中运行,必须设置为与
#系统时区相同。
TIME_ZONE ='美国/芝加哥'

#此安装的语言代码。所有选择都可以在这里找到:
#http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE ='en-us'

SITE_ID = 1

#如果将其设置为False,Django将进行一些优化,以便
#加载国际化机器。
USE_I18N = True

#如果将其设置为False,Django将不会根据当前语言环境格式设置日期,数字和
#日历。
USE_L10N = True

#如果将其设置为False,Django将不会使用时区感知数据时间。
USE_TZ = True

#将保存用户上传文件的目录的绝对文件系统路径。
#示例:/home/media/media.lawrence.com/media/
MEDIA_ROOT =''

#处理从MEDIA_ROOT提供的媒体的URL。确保使用
#尾部斜线。
#示例:http://media.lawrence.com/media/,http://example.com/media/
MEDIA_URL =''

#静态文件的绝对路径应该被收集到。
#不要把任何东西放在这个目录下;在应用程序的static /子目录和STATICFILES_DIRS中存储静态文件
#。
#示例:/home/media/media.lawrence.com/static/
STATIC_ROOT =''

#静态文件的URL前缀。
#示例:http://media.lawrence.com/static/
STATIC_URL ='/ static /'

#静态文件的附加位置
STATICFILES_DIRS =(
#将字符串放在这里,像/ home / html / static或C:/ www / django / static
#总是使用正斜杠,甚至在Windows上
#不要忘记使用绝对路径,而不是相对路径。
'C:\Users\Megapayo\Desktop\Laurent_practica\pruebasdjango\proyecto\clinica\static',


#了解如何在
#各个位置找到静态文件的finder类列表。
STATICFILES_FINDERS =(
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#'django.contrib.staticfiles .finders.DefaultStorageFinder',


#使其独一无二,不要与任何人共享。
SECRET_KEY ='* 0orv& amp; yy * kbscyvd!k& amp; x8 @ -u!(2g1998 $ 7sd_ @ ig + 4e5kz(0& amp; t'

#知道如何从各种来源导入模板的callables
TEMPLATE_LOADERS =(
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader' ,
#'django.template.loaders.eggs.Loader',


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',
#取消注释下一行的简单点击保护:
#'django.middleware.clickjacking.XFrameOptionsMiddleware',


ROOT_URLCONF ='clinica.urls'

#Python虚线路径到WSGI应用程序
WSGI_APPLICATION ='clinica.wsgi.application'

TEMPLATE_DIRS =(
#将字符串放在这里,如/ home / html / django_templates或 C:/ WWW / Django的/模板。
#总是使用正斜杠,甚至在Windows上。
#不要忘记使用绝对路径,而不是相对路径。
r'C:\Users\Megapayo\Desktop\Laurent_practica\pruebasdjango\proyecto\mySite\paginasWeb',


INSTALLED_APPS =(
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
#取消注释下一行以启用管理员:
'django.contrib.admin',
'clinica',

#取消注释下一行以启用管理员文档:
#'django.contrib.admindocs',


#采样记录配置。通过此配置执行的唯一有形日志
#是在DEBUG = False时向每个HTTP 500错误发送电子邮件至
#的网站管理员。
#有关如何自定义日志配置的详细信息,请参阅http://docs.djangoproject.com/en/dev/topics/logging for
#。





LOGGING = {
'version':1,
'disable_existing_loggers':False,
'filters':{
'require_debug_false':{
'()':'django.utils.log.RequireDebugFalse'
}
},
' ':{
'mail_admins':{
'level':'ERROR',
'filters':['require_debug_false'],
'class':'django.utils .log.AdminEmailHandler'
}
},
'loggers':{
'django.request':{
'处理程序':['mail_admins'],
'level':'ERROR',
'propagate':True,
},
}
}
/ pre>

解决方案

好的,所以要注销我不会使用/ admin / logout /但是/ logout / )



如何配置Django注销后重定向到哪里?

 (r'^ logout / $','django.contrib.auth.views.logout',
{'next_page':'/ successfully_logged_out /'})
/ pre>

感谢您回答这个快速


i have put the setting LOGOUT_URL ='http://www.google.fr but when I log out, it still goes to the default url '/accounts/logout/' and what ever other url redirection. I have seeked everywhere and i realy don't know why it is not working

# Django settings for clinica project.

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
    ('admin', 'admin@fr.fr'),
)

MANAGERS = ADMINS


LOGOUT_URL ='http://www.google.fr'

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': r'C:\Users\Megapayo\Desktop\Laurent_practica\pruebasdjango\proyecto\clinica\sqlite.db',# Or path to database file if using sqlite3.
        'USER': '',                      # Not used with sqlite3.
        'PASSWORD': '',                  # Not used with sqlite3.
        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
    }
}

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'America/Chicago'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True

# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale.
USE_L10N = True

# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = True

# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = ''

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = ''

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = ''

# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'

# Additional locations of static files
STATICFILES_DIRS = (
    # Put strings here, like "/home/html/static" or "C:/www/django/static".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
    'C:\Users\Megapayo\Desktop\Laurent_practica\pruebasdjango\proyecto\clinica\static',
)

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

# Make this unique, and don't share it with anybody.
SECRET_KEY = '*0orv&yy*kbscyvd!k&x8@-u!(2g1998$7sd_@ig+4e5kz(0&t'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
#     'django.template.loaders.eggs.Loader',
)

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',
    # Uncomment the next line for simple clickjacking protection:
    # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'clinica.urls'

# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'clinica.wsgi.application'

TEMPLATE_DIRS = (
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
    r'C:\Users\Megapayo\Desktop\Laurent_practica\pruebasdjango\proyecto\mySite\paginasWeb',
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # Uncomment the next line to enable the admin:
    'django.contrib.admin',
    'clinica',

    # Uncomment the next line to enable admin documentation:
    # 'django.contrib.admindocs',
)

# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.





LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        }
    },
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'filters': ['require_debug_false'],
            'class': 'django.utils.log.AdminEmailHandler'
        }
    },
    'loggers': {
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': True,
        },
    }
}

解决方案

Ok, so to log out I won't use the /admin/logout/ but the /logout/ :)

How to configure where to redirect after a log out in Django?

(r'^logout/$', 'django.contrib.auth.views.logout',
                      {'next_page': '/successfully_logged_out/'})

Thank you for answering that fast

这篇关于Django,Logout_URL不会很好地重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆