小编Ash*_*ish的帖子

django 模板按原样显示 html 标签

下面是我的工作区/项目名称/模板/应用名称中的 index.html 文件

<!DOCTYPE html>
<html>

    <head>
        <title>my news</title>
    </head>

    <body>
        <h1>look below for news</h1>
        {%if categories%}
            <ul>
                {%for category in categories%}
                    <li>{{category.name}}</li>

                {%endfor%}
            </ul>

        {%endif%}

        {%if headings%}

            <p>
                {%for heading in headings%}

                    <a href="#">{{heading.title}}</a>
                    <br>
                    {{heading.content}}

                {%endfor%}
            </p>

        {%endif%}
    </body>

</html>
Run Code Online (Sandbox Code Playgroud)

问题是<ul><li>标签的工作,并显示是否应该do.the列表<a>标记也显示超链接,但<p>标签和<br>标签没有被渲染并正在显示为文本,不能认为可能是什么疑难问题。我对 Django 相当陌生。 索引.html

html python django

2
推荐指数
1
解决办法
2507
查看次数

在jquery中正确使用$(this)

    $(".gear_listing").hover(function(){

            $(".overlay_gears").show();
        },function(){
   $(".overlay_gears").hide();
}
    );
Run Code Online (Sandbox Code Playgroud)

上面是我的jquery代码,你可以想象我试图显示.overlay_gears div当.gear_listing div悬停时,上面的代码工作正常.问题是我有很多.gear_listing div和许多.overlay_gears div当我将鼠标悬停在任何名为.gear_listing的div上时,显示所有.overlay_gears div,我不想要.我只想在.gear_listing div.i下显示.overlay_gears div.我知道我必须使用$(this).我只是不知道如何.

我试过这样做:

    $(".gear_listing").hover(function(){
        var this=$(this);
            this.$(".overlay_gears").show();
        },function(){
   this.$(".overlay_gears").hide();
}
    );
Run Code Online (Sandbox Code Playgroud)

它不起作用

下面是我的div结构:

               <li>
                    <a href="#">
                        <div class="gear_listing relative">

                            <div class="overlay_gears absolute"></div>
                            <div class="gear_description absolute">
                                <span>afdfdsfds sfd</span>
                            </div>

                            <img src="images/list_one.jpg">
                        </div>
                    </a>
                </li>

                <li>
                    <a href="#">
                        <div class="gear_listing relative">
                            <div class="overlay_gears absolute"></div>
                            <div class="gear_description absolute">
                                <span>afdfdsfds sfd</span>
                            </div>
                            <img src="images/list_two.jpg">
                        </div>
                    </a>
                </li>

                <li>
                    <a href="#">
                        <div class="gear_listing relative">
                            <div class="overlay_gears absolute"></div>
                            <div class="gear_description absolute">
                                <span>afdfdsfds sfd</span>
                            </div> …
Run Code Online (Sandbox Code Playgroud)

html javascript css jquery

2
推荐指数
2
解决办法
123
查看次数

django 模板锚标记不起作用

我的网页中有一个标题,该标题中有一个徽标。我想在该徽标中插入一个锚标记,该标记指向我的主页,即 index.html 页面,尽管调用了哪个视图或页面。我创建了一个 base.html,其中的一个片段是:

<div class="header">
            <div class="inner_header">
                <div class="logo">

                    <a href='#'><img src="{% static 'images/logo.png' %}" alt="logo" /> </a>

                </div>
Run Code Online (Sandbox Code Playgroud)

我已将此 base.html 扩展到所有其他模板文件

我指向我的索引页和其他页面的 url 模式是这样的:

 urlpatterns = patterns('',
        url(r'^$', views.index, name='index'),
        url(r'^category/(?P<category_name_slug>[\w\-]+)/$', views.category, name='category'),
        url(r'^latest/(?P<latest_title_slug>[\w\-]+)/$', views.latest, name='latest'),
        url(r'^headline/(?P<heading_title_slug>[\w\-]+)/$', views.headline, name='headline'),)
Run Code Online (Sandbox Code Playgroud)

我试过使用<a href="index.html">,<a href=''>和其他一堆不会产生预期结果或给出错误的东西。在不编写大量代码的情况下执行此操作的适当方法是什么?

python django django-templates django-urls

1
推荐指数
1
解决办法
2310
查看次数

标签 统计

django ×2

html ×2

python ×2

css ×1

django-templates ×1

django-urls ×1

javascript ×1

jquery ×1