#22007 closed Cleanup/optimization (fixed)
Make import paths more consistent in documentation
Reported by: | Owned by: | Martin Matusiak | |
---|---|---|---|
Component: | Documentation | Version: | 1.6 |
Severity: | Normal | Keywords: | import module, import script, nlsprint14 |
Cc: | Martin Matusiak | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
I am getting thrown by the documentation (https://docs.djangoproject.com/en/1.6/topics/class-based-views/intro/#using-class-based-views), when they give this example:
from django.http import HttpResponse
from django.views.generic.base import View
class MyView(View):
def get(self, request):
# <view logic>
return HttpResponse('result')
For the first import, they are specifying only the folder names and omitting the actual python script which contains the definition of class HttpResponse
, which is response.py
. Here they are relying on the __init__.py
to work.
For the second import, they are not relying on the __init__.py
and going all the way to specify the python script in which the class View
is defined, which is base.py
.
If the first way is preferred, then the second import should be written as:
from django.views.generic import View
If the second way is preferred, then the first import should be written as:
from django.http.request import HttpRequest
I know that both are acceptable. I am just wondering why both are being used and not just one style. I think this is important because this will be what people will be writing in the code.
I would very much love to see this (and other occurrences of this) to be identified and cleaned up.
Change History (6)
comment:1 by , 11 years ago
comment:3 by , 11 years ago
Summary: | Mixed import styles (possible OCD on my part) → Make import paths more consistent in documentation |
---|---|
Triage Stage: | Unreviewed → Accepted |
I think using the "convenience imports" (e.g. from django.http import HttpResponse
) is probably the way to go.
comment:4 by , 11 years ago
Cc: | added |
---|---|
Keywords: | nlsprint14 added |
Owner: | changed from | to
Status: | new → assigned |
comment:5 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Is this really a big deal?