2017-03-09 13 views
0

オンライン書店を構築しようとしていて、django登録を使用しています。私は2ウェイ確認ログインシステムを構築しました。ユーザーのログイン後、メインのホームページ(私の場合は/ store)にリダイレクトしたいのですが、なんらかの理由でアカウント/プロフィールに向いていますが、どこからこのURLを取得しているのか分かりません。ログイン後にDjangoが目的のURLにリダイレクトしない

は、ここに私のSettings.pyコード

import os 

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 


# Quick-start development settings - unsuitable for production 
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/ 

# SECURITY WARNING: keep the secret key used in production secret! 
SECRET_KEY = '&icg8)16be&h!rw)6_#3#v!1dn5nx_*[email protected](88tw5z6$a' 

# SECURITY WARNING: don't run with debug turned on in production! 
DEBUG = True 

ALLOWED_HOSTS = [] 


# Application definition 

INSTALLED_APPS = (

    'django.contrib.admin', 
    'django.contrib.auth', 
    'django.contrib.contenttypes', 
    'django.contrib.sessions', 
    'django.contrib.messages', 
    'django.contrib.staticfiles', 
    'social.apps.django_app.default', 
    'store', 
    'registration', 
) 

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', 
    'django.middleware.clickjacking.XFrameOptionsMiddleware', 
    'django.middleware.security.SecurityMiddleware', 
) 

ROOT_URLCONF = 'bookstore.urls' 

TEMPLATES = [ 
    { 
     'BACKEND': 'django.template.backends.django.DjangoTemplates', 
     'DIRS': [], 
     'APP_DIRS': True, 
     'OPTIONS': { 
      'context_processors': [ 
       'django.template.context_processors.debug', 
       'django.template.context_processors.request', 
       'django.contrib.auth.context_processors.auth', 
       'django.contrib.messages.context_processors.messages', 
       'social.apps.django_app.context_processors.backends', 
       'social.apps.django_app.context_processors.login_redirect', 
      ], 
     }, 
    }, 
] 

WSGI_APPLICATION = 'bookstore.wsgi.application' 

AUTHENTICATION_BACKENDS = (
    'social.backends.facebook.FacebookOAuth2', 
    'django.contrib.auth.backends.ModelBackend' 
) 

# Database 
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases 

DATABASES = { 
    'default': { 
     'ENGINE': 'django.db.backends.sqlite3', 
     'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 
    } 
} 


# Internationalization 
# https://docs.djangoproject.com/en/1.8/topics/i18n/ 

LANGUAGE_CODE = 'en-us' 

TIME_ZONE = 'UTC' 

USE_I18N = True 

USE_L10N = True 

USE_TZ = True 


# Static files (CSS, JavaScript, Images) 
# https://docs.djangoproject.com/en/1.8/howto/static-files/ 

STATIC_URL = '/static/' 


# Registration 

ACCOUNT_ACTIVATION_DAYS = 7 
REGISTRATION_AUTO_LOGIN = True 
LOGIN_REDIRECT_USER = "/store/" 

そして、ここでは私のurls.pyです

from django.conf.urls import include, url 
from django.contrib import admin 

urlpatterns = [ 
    # Examples: 
    # url(r'^$', 'bookstore.views.home', name='home'), 
    # url(r'^blog/', include('blog.urls')), 
    url(r'^admin/', include(admin.site.urls)), 

    url (r'^store/', include('store.urls'), name='store'), 
    url(r'^accounts/', include('registration.backends.default.urls')), 
    url ('', include('social.apps.django_app.urls', namespace = 'social')), 

そして私のlogin.htmlと

<form method = "post" action ="."> 
    {% csrf_token %} 
    {{ form.as_p }} 
    <input type = "submit" value="LogIn"/> 
    <input type = "hidden" name = "next" value = "{{next}}"/> 
</form> 

<a href = " {% url 'social:begin' 'facebook' %}"> Login With Facebook</a> 

はヘルプが大幅

+0

あなたの 'views.py'も共有してください。 –

+0

通常のログインやフェイスブックによるログインのエラーですか? "/ store /"は存在しますか?または 'r"の子URLのない唯一のルートです^^"' –

答えて

0
を高く評価されています

あなたは設定名が間違っています。あなたはです。

+0

* facepalm *私はそこでエラーを期待して5回目を見ましたが、ちょうどそれを見ることができませんでした –

+0

くそー!!どうもありがとう !!タイプミスは数時間私の脳を流した...ありがとう:D –