Django - How to pass several arguments to the url template tag

后端 未结 3 1513
梦如初夏
梦如初夏 2021-02-12 11:15

In my urls.py I have:

(r\'^(?P\\d{4})/(?P\\d{2})/(?P\\d{2})/section/(?P[-\\w]+)/$\', 
    \'paper.views.issue_sec         


        
3条回答
  •  甜味超标
    2021-02-12 11:56

    I had the same issue (I'm using Django 1.3.1) and tried Gregor Müllegger's suggestion, but that didn't work for two reasons:

    • there should be no commas between year, month and day values
    • my class-based generic view seems to take only keyword arguments

    Thus the only working solution was:

    {% url news_detail slug=object.slug year=object.date|date:"Y" month=object.date|date:"m" day=object.date|date:"d" %}
    

提交回复
热议问题