私はe-commアプリケーションで作業しています。ユーザー登録とログインの設定にdjango registration reduxを使用しています。最初は私がregister/loginシステムをセットアップしたときに、うまく動作していました。私がbase.htmlにブートストラップとスタイルを置くと、機能が壊れ、ユーザログイン後にbase.htmlにリダイレクトされました。http://localhost:8000/accounts/login/、このURLは..ログイン後にdjango登録の還元がbase.htmlにリダイレクトされない
私は理由を理解できないようです。
こちらは私の設定です また、インストールされたアプリケーションセクションの最後に「store」を置き、login/register URLをクリックしようとすると、login/registerページではなく、urlがbase.htmlに戻ります。
"あなたは、設定に少し変更を加える必要はありbase.htmlにリダイレクトする"」
Django settings for bookstore project.
Generated by 'django-admin startproject' using Django 1.8.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
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: 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',
'bootstrap3',
'bootstrap_themes',
)
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_URL = "/store/"
base.html
{% extends 'bootstrap3/bootstrap3.html' %}
{% load staticfiles %}
{% load bootstrap3 %}
{% load bootstrap_themes %}
{% bootstrap_styles theme='simplex' type='min.css' %}
{% block bootstrap3_extra_head %}
<link href = "http://fonts.googleapis.com/css?family=Open+Sans:400,300,700" rel = "stylesheet" type="text/css"/>
<link href = "{% static 'base/css/style.css' %}" rel = "stylesheet" type="text/css"/>
{% endblock %}
{% block bootstrap3_title %}
{% block title %}
Welcome to Pick A Book !!
{% endblock %}
{% endblock %}
{% block bootstrap3_content %}
<nav class = "navbar navbar-inverse navbar-fixed-top">
<div class = "container">
<div class = "navbar-header">
<button type="button" class ="navbar-toggle" data-toggle="collapse" data-target = "#navbar">
<span class = "icon-bar"> </span>
<span class = "icon-bar"> </span>
<span class = "icon-bar"> </span>
</button>
<a href="{% url 'index' %}" class="navbar-brand">Pick A Book </a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="hvr-curl-top-right"><a href="{% url 'index' %}">Home</a></li>
<li class="hvr-curl-top-right"><a href="#about">About</a></li>
<li class="hvr-curl-top-right"><a href="#contact">Contact</a></li>
</ul>
<div class="navbar-form pull-right">
{% if request.user.is_authenticated %}
Welcome, {% if request.user.first_name %}
{{ request.user.first_name}}
{% else %}
{{ request.user.username }}
{% endif %}! <a href="(% url 'auth_logout' %}"> Log Out</a>
{% else %}
Welcome, mysterious person! <a href="{% url 'auth_login' %}">Log In? </a> or <a href="{% url 'registration_register' %}">Register</a>
{% endif %}
</div>
</div>
</div>
</nav>
<div class="container-fluid">
<img src="{% static 'base/img/header_full.jpg' %}" class ="bg">
<div class="parallax">
<div class="row">
{% block body %}
<div class="col-md-8 col-md-offset-2 col-sm-12 maincontent">
Welcome to our store!
</div>
{% endblock %}
</div>
</div>
</div>
<div class="row text-center navbar footer">
<div class="col-md-12">
<p> 2017 Pick A Book. Developed by <a href="http://kshitijrangai.com"> Kshitij Rangari </a> </p>
</div>
</div>
{% endblock %}
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')),
]