我正在使用Django 1.10。技術上這篇文章是關於Django-registration-redux的,但是SO不會讓我創建一個新的標籤來發布這個問題。 Django-registration-redux沒有看到註冊模板。我將所有模板複製到我的模板文件夾中名爲「註冊」的文件夾中。雖然我沒有得到一個錯誤。例如,當我去/ accounts/register它呈現一些表單,但它不是我的模板/註冊文件夾。林不知道我做錯了什麼。我甚至完全刪除模板/註冊文件夾,甚至沒有發生錯誤。我閱讀了一些類似的帖子,人們不得不將註冊移動到已安裝的應用程序的頂部,因此它不會使用我嘗試過並且沒有幫助的管理員表單。到目前爲止沒有任何改變。所有的模板都會擴展基礎。Django註冊Redux沒有看到我的模板/註冊模板
所以我猜我配置了錯誤的東西。有點奇怪。所有的功能都在那裏,但它只是沒有使用我的模板。對不起,如果它是一個愚蠢的問題,但我會感謝一些幫助!
pip freeze
Django==1.10
django-crispy-forms==1.6.0
django-registration-redux==1.4
INSTALLED_APPS = [
'registration',
'django.contrib.admin',
'django.contrib.sites',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# third party
'crispy_forms',
# my apps
'todo',
]
# Django registration redux settings
ACCOUNT_ACTIVATION_DAYS = 7
REGISTRATION_OPEN = True
REGISTRATION_AUTO_LOGIN = True
LOGIN_REDIRECT_URL = '/' # The page you want users to arrive at after they successful log in
LOGIN_URL = '/accounts/login/'
SITE_ID = 1
這裏是我的/templates/registration/registration_form.html
{% extends "base.html" %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block content %}
<div class='row'>
<div class='col-sm-6 col-sm-offset-3'>
<h1>Register for free!</h1>
<form method="post" action=".">
{% csrf_token %}
{{ form|crispy }}
<input class='btn btn-block btn-primary' type="submit" value="{% trans 'Join' %}" />
</form>
</div>
</div>
<hr/>
<div class='row'>
<div class='col-sm-6 col-sm-offset-3 text-align-center'>
<p>Need to <a href="{% url 'auth_login' %}">Login</a>?</p>
</div>
</div>
{% endblock %}
this is a screenshot showing the form I see at accounts/register
我能夠得到它的工作,但這不能是最好的方法。我進入我的virtualenv的網站包到django註冊包,並找到包含它實際呈現的模板的模板文件夾。爲了測試,我將實際的django註冊應用程序中的模板文件夾重命名爲registration_temp,並且我猜測它何時無法再找到自己的模板來強制它看到我的模板。是否有我缺少的設置,告訴django註冊使用自己的模板或你的?我使用pip安裝,所以我認爲其他人也會遇到這個問題。 – davesharp