0

1. I have a base.html template that just describe the site (the basic simple base.html) 2. I have a split_screen.html template that extends the base,html file and look like this:

{% extends "base.html" %}

{% block content %} - this is the part that changes in base.
    <div id="top"> 
        here come the login form and under it a logo and then a top nav pannel 
    </div>
    <div id="right">
        here come a static right nav pannel that never change, so there is no need for a block
    </div>
    <div id="main">
        {% block main%}
        this is the main part, this is the only thing that will change with every page in (all the files) that will extend from split_screen.html (every other page in the site).
        {% endblock %}
    </div>
{% endblock %}

OK, i guess that now is a time for a question... so, what i am looking for and can't find (or maybe just can't understand how to implement) is way to use template inheritance and still have this login backend view that i built (using email instead of username) implemented....I just can't figure this one out because every example i read i referring to login as a page of its own, i need it to be embedded in this page (or don't i?).

Can any one please help with this?

4

1 回答 1

0

好的,我已经解决了这个问题,我不想使用中间件也没有使用它,但是通过结合 fe 教程和技巧,我想我得到了一切。

  1. 构建一个主模板(扩展 base.html),其中包括表单
  2. 构建一个将继承它的 mamber 模板。
  3. 创建一个简单的索引视图(在您网站的主目录中,其中除了您构建的主模板的返回渲染之外什么都没有(用于在网站上传时加载主页
  4. 第二个视图是登录的后端,具有身份验证过程“/backend.py”,并将返回成功登录的用户的用户实例或无
  5. 创建自定义登录视图,该视图将获取 emain 和密码字段的 request.POST(在检查您是否在帖子中之后 - 所以您不会得到不好的结果,可能会和 bouble 发布和类似的东西)获取用户实例从后端身份验证方法检查是否不是无,然后检查是否为有效,如果两者都转到成员页面,如果不转到同一页面(将获取但默认值,因此您不必在视图末尾放置重定向为这种情况渲染(与 reques.POST if 相同的级别。

好吧,基本上就是这样,现在,无论我在哪里,每个请求都会通过这个,因为我扩展了我们在开始时为网站的其余部分构建的主模板......

现在看来它工作得很好,如果有人有问题或意见我会很高兴听到他们...10x

于 2011-05-11T08:26:47.033 回答