2013-03-07 14 views
5

se provo:Django 1.5. 'url' richiede un primo argomento non vuoto. La sintassi cambiato in Django 1.5

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

ho questo errore:

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

come cambiarlo?

+0

Se è necessario supportare Django 1.3 e 1.5 avere un lok in questa risposta: http://stackoverflow.com/questions/14882491/django-release-1-5-url-requires-a-non-empty-first -argument-the-sintassi-change – guettli

risposta

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.

Quindi: "{% url 'post_content' product_id=p.id %}".

Problemi correlati