#32419 closed Cleanup/optimization (fixed)
"Serving files uploaded by a user during development" example unclear about "urls.py"
Reported by: | Josef Richter | Owned by: | Amankumar Singh |
---|---|---|---|
Component: | Documentation | Version: | 3.1 |
Severity: | Normal | Keywords: | media, uploads, images, forms, MEDIA_URL, MEDIA_ROOT, tutorial |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
Documentation at https://docs.djangoproject.com/en/3.1/howto/static-files/#serving-files-uploaded-by-a-user-during-development suggests amendments to urls.py
If you followed the "Writing your first Django app" tutorial over here https://docs.djangoproject.com/en/3.1/intro/tutorial01/, you may end up with two files mysite/urls.py
and polls/urls.py
and likely to make the above amendment to polls/urls.py
, which is incorrect. The files in that case get uploaded to polls/media/images
and then cannot be served (404). The documentation should make it clear the amendment needs to be done in mysite/urls.py
.
For a person writing Django code for the very first time this is not obvious. I resolved the issue with the help of Django IRC community.
Change History (7)
comment:1 by , 4 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 4 years ago
Triage Stage: | Unreviewed → Accepted |
---|
follow-up: 6 comment:3 by , 4 years ago
Summary: | MEDIA_URL and MEDIA_ROOT configuration ambiguous; suggested adjustment → "Serving files uploaded by a user during development" example unclear about "urls.py" |
---|
comment:6 by , 4 years ago
Replying to Tim Graham:
It seems like a basic understanding of how the URL system works would get you to the right answer, but... would it be more clear to you if it said, "you can do this by adding the following snippet to your
ROOT_URLCONF
" (changingurls.py
toROOT_URLCONF
). I don't think referencing the filenames in the tutorial here is a good idea.
Yes, probably. I'm just saying it's an easy mistake to make for a beginner who sees Django for the first time in their life and don't know the details of its URL system, structuring the app, etc. And it's hard to identify and fix that mistake for a beginner.
It seems like a basic understanding of how the URL system works would get you to the right answer, but... would it be more clear to you if it said, "you can do this by adding the following snippet to your
ROOT_URLCONF
" (changingurls.py
toROOT_URLCONF
). I don't think referencing the filenames in the tutorial here is a good idea.