Opened 9 years ago
Last modified 3 years ago
#26661 new Cleanup/optimization
Why not using AppConfig's name attribute instead of app_name in urls.py?
Reported by: | john-bonachon | Owned by: | nobody |
---|---|---|---|
Component: | Core (URLs) | Version: | 1.9 |
Severity: | Normal | Keywords: | |
Cc: | Marten Kenbeek | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Pull Requests: | How to create a pull request | ||
Description ¶
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.
According to the ticket's flags, the next step(s) to move this issue forward are:
- To provide a patch by sending a pull request. Claim the ticket when you start working so that someone else doesn't duplicate effort. Before sending a pull request, review your work against the patch review checklist. Check the "Has patch" flag on the ticket after sending a pull request and include a link to the pull request in the ticket comment when making that update. The usual format is:
[https://github.com/django/django/pull/#### PR]
.
Change History (6)
comment:1 by , 9 years ago
Cc: | added |
---|
follow-up: 3 comment:2 by , 9 years ago
Component: | Core (Other) → Core (URLs) |
---|---|
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Cleanup/optimization |
We might end up changing the ticket to a documentation issue to explain the design.
comment:3 by , 9 years ago
Replying to timgraham:
We might end up changing the ticket to a documentation issue to explain the design.
Oh.. no interest in reusing the app name?
comment:4 by , 9 years ago
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.
comment:5 by , 3 years ago
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.
comment:6 by , 3 years ago
I would just like to add its really confusing to call the url namespace attribute app_name
, which is associated with the AppConfig.name
, the same as how one uses app_name
in the context of working with models. This inconsistency creates a false assumption to one trying to learn how this machinery works.
I recommend a different name, something like url_namespace
, that would be explicit, and self evident.
I seems to remember discussing this during the development of this feature (#21927) but I'm not certain. Marten, do you recall?