简体   繁体   English

django 1.3模板标签url意外结果

[英]django 1.3 template tag url unexpected result

template: 模板:

            <!-- Images slide as a row starts -->
            <!-- power.views.IMAGE_SLIDES_ROW returns image_slider_row/   -->
            {% url power.views.IMAGE_SLIDES_ROW %} 
            <!-- Images as a row Ends -->

url conf: 网址配置:

     url(r'^image_slider_row/', views.images_slider_row_func, name='image_slider_row'),

View : 查看:

def images_slider_row(request):
    print "Debug-1"
    return render_to_response('images_slider_row.html', {})

actually I am expecting "images_slider_row_func" will get call on url tag execution but it is not happening, it is showing following string in the browser 实际上,我期望“ images_slider_row_func”将在执行URL标记时被调用,但是这没有发生,它在浏览器中显示以下字符串

/images_slider_row/ / images_slider_row /

am I missing anything or am I misunderstood the concept? 我错过了什么还是我误解了这个概念? Please help me for fixing this issue. 请帮助我解决此问题。

Basically, the url method takes the parameters for the regular expression matching the accessed URL, the function to call (in this case, images_slider_row_func) and with the keyword arg name the name that can be used as shown in your template to identify that function when calling the url "macro". 基本上, url方法采用与访问的URL相匹配的正则表达式的参数,要调用的函数(在本例中为images_slider_row_func),并使用关键字arg name作为名称,可以使用模板中显示的名称来标识该函数。将该网址称为“宏”。

However, django should try to access the function "images_slider_row_func" when accessing the URL "/images_slider_row/" (notice the difference here!) 但是,django在访问URL“ / images_slider_row /”时应尝试访问函数“ images_slider_row_func”(注意此处的区别!)

使用<a href="{% url image_slider_row %}">foo bar</a>作为示例,templatetag url期望urls.py来自您的name参数

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM