2013-03-07 20 views
5

Nếu tôi cố gắng:Django 1.5. 'url' yêu cầu đối số đầu tiên không trống. Cú pháp thay đổi trong Django 1,5

href="{% url post_content product_id=p.id %}" 

Tôi có lỗi này:

'url' requires a non-empty first argument. The syntax changed in Django 1.5, see the docs.

Làm thế nào để thay đổi nó?

+0

Nếu bạn cần hỗ trợ Django 1.3 và 1.5 có một lok tại câu trả lời này: http://stackoverflow.com/questions/14882491/django-release-1-5-url-requires-a-non-empty-first -argument-the-syntax-change – guettli

Trả lời

9

Changed in Django 1.5: The first parameter used not to be quoted, which was inconsistent with other template tags. Since Django 1.5, it is evaluated according to the usual rules: it can be a quoted string or a variable that will be looked up in the context.

Vì vậy: "{% url 'post_content' product_id=p.id %}".

Các vấn đề liên quan