That question should be posted on Django user, where people discuss on how
to use django to build web site and web application. This list is for
improving djnago.

Anyway.
The first argument of the url tag is the name of the URL you want. The most
common way to specify an URL name is with the format "{app}:{url}". This
let you have each app have an home view without conflict and you can still
can fetch the URL from the right app.

The name of an app is always stored in a variable app_name. And URL won't
alter the URL name you gave it. So if you ask for 'app_name:posts', you
will get the URL named posts from the app with a variable app_name set to
the value app_name.


Maybe you are thinking of relative URL name resolving, which would be an
improvement to Django. What I mean is the url tag would recognize a special
value as meaning "fetch that view from the current app".

In my opinion, either a blank app name or 'self' would be a better choice
for that special value. And it would cause a lot of issue. It might break
existing Django app, which is bad. It will make finding all references if
an URL in you code harder as you need to search for both the absolute and
the relative name version.


I hope this answer your questions and thanks for asking


On Thu, 12 Jul 2018, 03:55 Aniket Aryamane, <[email protected]>
wrote:

> Hello,
>
> If in the urls.py, I can write:
> *app_name* = '*posts*'
> .
> .
> path(' ', views.home, name='home'),
>
>
>
> then why it is required to refer url name (from the template) by the *app_name
> value* as:
> {% url '*posts*:home' %}
>
> It should be referred instead by *app_name variable* like below:
> {% url '*app_name*:home' %}
>
>
> What do you guys think?
>
>
>
> Thanks,
> Aniket.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/django-developers.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/ce6c2ef7-b463-43d5-bd57-5f2ca3d6fda6%40googlegroups.com
> <https://groups.google.com/d/msgid/django-developers/ce6c2ef7-b463-43d5-bd57-5f2ca3d6fda6%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.a
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAEuG%2BTa26uoFDhjUujV_iWsNtBzx_1fvb5G2G3yfotUTzxLEBw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to