Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django 使用@login\u必需的装饰器_Django_Django Templates_Django Views_Django Authentication_Django Login - Fatal编程技术网

Django 使用@login\u必需的装饰器

Django 使用@login\u必需的装饰器,django,django-templates,django-views,django-authentication,django-login,Django,Django Templates,Django Views,Django Authentication,Django Login,这是我第一次使用用户身份验证编写自定义视图。几个小时以来我一直被困在这里,因为我真的不知道使用@login\u required decorator应该注意什么或者应该注意什么。以下是我的观点.py: 以下是我的应用程序URL.py: 这是login.html模板: {% block body %} <header> <h1>Login Page</h1> </header> <section> {% if for

这是我第一次使用用户身份验证编写自定义视图。几个小时以来我一直被困在这里,因为我真的不知道使用@login\u required decorator应该注意什么或者应该注意什么。以下是我的观点.py:

以下是我的应用程序URL.py:

这是login.html模板:

{% block body %}
 <header>
  <h1>Login Page</h1>
 </header>

  <section>
    {% if form.errors %}
      <p>Your username and password didn't match, please try again.</p>
    {% endif %}

    <form method="post" action=".">
      {% csrf_token %}
      <p>
        <label for="id_username">Username:</label>
        {{ form.username }}
      </p>
      <p>
        <label for="id_password">Password:</label>
        {{ form.password }}
      </p>
      {% if next %}
        <input type="hidden" name="next" value="{{ next }}" />
      {% else %}
        <input type="hidden" name="next" value="/programm/liste.html" />
      {% endif %}
      <input type="submit" value="login" />
    </form>   </section> {% endblock %}
  </section>
{% endblock %}

您还没有向我们显示模板的布局-登录视图希望login.html模板位于文件夹注册中。

我没有看到任何代码来执行实际的登录过程。我认为使用@login\u required decorator可以将自定义django登录视图称为Oo
from django.conf.urls import patterns, url
from programm import views
from django.conf import settings

urlpatterns = patterns('',
        url(r'^$', views.index, name = 'index'),
        url(r'^liste.html$', views.liste, name = 'liste'),
)
{% block body %}
 <header>
  <h1>Login Page</h1>
 </header>

  <section>
    {% if form.errors %}
      <p>Your username and password didn't match, please try again.</p>
    {% endif %}

    <form method="post" action=".">
      {% csrf_token %}
      <p>
        <label for="id_username">Username:</label>
        {{ form.username }}
      </p>
      <p>
        <label for="id_password">Password:</label>
        {{ form.password }}
      </p>
      {% if next %}
        <input type="hidden" name="next" value="{{ next }}" />
      {% else %}
        <input type="hidden" name="next" value="/programm/liste.html" />
      {% endif %}
      <input type="submit" value="login" />
    </form>   </section> {% endblock %}
  </section>
{% endblock %}
TemplateDoesNotExist at /login/

registration/login.html

Request Method:     GET
Request URL:    http://10.0.3.107:8000/login/?next=/programm/liste.html
Django Version:     1.6.1
Exception Type:     TemplateDoesNotExist
Exception Value:    

registration/login.html

Exception Location:     /usr/local/lib/python2.7/dist-packages/django/template/loader.py in find_template, line 131
Python Executable:  /usr/bin/python
Python Version:     2.7.3
Python Path:    

['/home/ubuntu/NachweisProj/ANachweis',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-linux2',
 '/usr/lib/python2.7/lib-tk',
 '/usr/lib/python2.7/lib-old',
 '/usr/lib/python2.7/lib-dynload',
 '/usr/local/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages']

Server time:    Wed, 19 Feb 2014 14:08:12 +0000