[Django] #26661: Why not using AppConfig's name attribute instead of app_name in urls.py?

20 views
Skip to first unread message

Django

unread,
May 24, 2016, 9:47:43 PM5/24/16
to django-...@googlegroups.com
#26661: Why not using AppConfig's name attribute instead of app_name in urls.py?
-------------------------------+--------------------
Reporter: john-bonachon | Owner: nobody
Type: Uncategorized | Status: new
Component: Core (Other) | Version: 1.9
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
In Django 1.9 you can namespace your urls by adding {{{app_name}}} in
urls.py

If the name will (generally) be the same as the containing module app, why
not just call it like that, or at least reusing the AppConfig name
attribute from apps.py?

Am I missing something? That's confusing when you are reading the tutorial
for the first time.

--
Ticket URL: <https://code.djangoproject.com/ticket/26661>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 26, 2016, 1:46:43 PM5/26/16
to django-...@googlegroups.com
#26661: Why not using AppConfig's name attribute instead of app_name in urls.py?
-------------------------------+--------------------------------------

Reporter: john-bonachon | Owner: nobody
Type: Uncategorized | Status: new
Component: Core (Other) | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by timgraham):

* cc: knbk (added)
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

I seems to remember discussing this during the development of this feature
(#21927) but I'm not certain. Marten, do you recall?

--
Ticket URL: <https://code.djangoproject.com/ticket/26661#comment:1>

Django

unread,
May 28, 2016, 3:30:45 PM5/28/16
to django-...@googlegroups.com
#26661: Why not using AppConfig's name attribute instead of app_name in urls.py?
--------------------------------------+------------------------------------
Reporter: john-bonachon | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Core (URLs) | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by timgraham):

* component: Core (Other) => Core (URLs)
* type: Uncategorized => Cleanup/optimization
* stage: Unreviewed => Accepted


Comment:

We might end up changing the ticket to a documentation issue to explain
the design.

--
Ticket URL: <https://code.djangoproject.com/ticket/26661#comment:2>

Django

unread,
May 28, 2016, 6:11:37 PM5/28/16
to django-...@googlegroups.com
#26661: Why not using AppConfig's name attribute instead of app_name in urls.py?
--------------------------------------+------------------------------------
Reporter: john-bonachon | Owner: nobody

Type: Cleanup/optimization | Status: new
Component: Core (URLs) | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by john-bonachon):

Replying to [comment:2 timgraham]:


> We might end up changing the ticket to a documentation issue to explain
the design.

Oh.. no interest in reusing the app name?

--
Ticket URL: <https://code.djangoproject.com/ticket/26661#comment:3>

Django

unread,
May 28, 2016, 6:44:09 PM5/28/16
to django-...@googlegroups.com
#26661: Why not using AppConfig's name attribute instead of app_name in urls.py?
--------------------------------------+------------------------------------
Reporter: john-bonachon | Owner: nobody

Type: Cleanup/optimization | Status: new
Component: Core (URLs) | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by timgraham):

I said "might" because I cannot recall the original design discussion and
say for certain whether or not the idea is a good one or is feasible to
implement.

--
Ticket URL: <https://code.djangoproject.com/ticket/26661#comment:4>

Django

unread,
Jun 9, 2022, 7:58:34 AM6/9/22
to django-...@googlegroups.com
#26661: Why not using AppConfig's name attribute instead of app_name in urls.py?
--------------------------------------+------------------------------------
Reporter: john-bonachon | Owner: nobody

Type: Cleanup/optimization | Status: new
Component: Core (URLs) | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by Carlton Gibson):

Closed #33774 as a duplicate: ''Where/how is the `application namespace`
defined?''.

> We might end up changing the ticket to a documentation issue to explain
the design.

Folks do get confused over namespaces, so a documentation review would
likely help.

--
Ticket URL: <https://code.djangoproject.com/ticket/26661#comment:5>

Django

unread,
Jul 15, 2022, 5:27:54 AM7/15/22
to django-...@googlegroups.com
#26661: Why not using AppConfig's name attribute instead of app_name in urls.py?
--------------------------------------+------------------------------------
Reporter: john-bonachon | Owner: nobody

Type: Cleanup/optimization | Status: new
Component: Core (URLs) | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by Michael):

I would just like to add its really confusing to call the url namespace
attribute `app_name`, which is associated with the `AppConfig.name`. It
immediately creates a false assumption to one trying to learn how this
machinery works. It tripped me up for years.

I recommend a different name, something like `url_namespace`, that would
be explicit, and self evident.

--
Ticket URL: <https://code.djangoproject.com/ticket/26661#comment:6>

Reply all
Reply to author
Forward
0 new messages