Friday, 15 January 2010

python - How to reference urls by view path instead of name in Django 1.8? -



python - How to reference urls by view path instead of name in Django 1.8? -

is necessary in django name urls utilize in url template tag?

the next url illustration given in documentation:

('^client/([0-9]+)/$', 'app_views.client', name='app-views-client')

and can used in template this:

{% url 'app-views-client' client.id %}

but there way reverse views path instead of name? there way deprecated in 1.8 , removed in django 2.0, this:

{% url 'path.to.some_view' v1 %}

in 1.8 , beyond there still way reverse view without naming it?

if want forwards compatible, named urls become necessary.

the deprecation timeline version 2 states:

the ability reverse() urls using dotted python path removed.

internally, url tag uses reverse, subject same deprecation. mentioned @ end of docs url tag.

if want reverse path still, @ the source how it's done now , replicate manually. there's reason behind decision remove ability.

python django django-urls

No comments:

Post a Comment