Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#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 Amankumar Singh, 3 years ago

Owner: changed from nobody to Amankumar Singh
Status: newassigned

comment:2 by Amankumar Singh, 3 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Tim Graham, 3 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"

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" (changing urls.py to ROOT_URLCONF). I don't think referencing the filenames in the tutorial here is a good idea.

comment:5 by GitHub <noreply@…>, 3 years ago

Resolution: fixed
Status: assignedclosed

In 51637222:

Fixed #32419 -- Clarified URLconf in example of serving media files.

in reply to:  3 comment:6 by Josef Richter, 3 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" (changing urls.py to ROOT_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.

comment:7 by Mariusz Felisiak <felisiak.mariusz@…>, 3 years ago

In d192d751:

[3.2.x] Fixed #32419 -- Clarified URLconf in example of serving media files.

Backport of 51637222b6eeed81d9ce6f5d24e22e249c605ba3 from master

Note: See TracTickets for help on using tickets.
Back to Top