[Django] #32419: MEDIA_URL and MEDIA_ROOT configuration ambiguous; suggested adjustment

30 views
Skip to first unread message

Django

unread,
Feb 4, 2021, 10:44:25 AM2/4/21
to django-...@googlegroups.com
#32419: MEDIA_URL and MEDIA_ROOT configuration ambiguous; suggested adjustment
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
josefrichter |
Type: | Status: new
Cleanup/optimization |
Component: | Version: 3.1
Documentation | Keywords: media, uploads,
Severity: Normal | images, forms, MEDIA_URL,
Triage Stage: | MEDIA_ROOT, tutorial
Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
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.

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

Django

unread,
Feb 4, 2021, 11:58:50 AM2/4/21
to django-...@googlegroups.com
#32419: MEDIA_URL and MEDIA_ROOT configuration ambiguous; suggested adjustment
-------------------------------------+-------------------------------------
Reporter: Josef Richter | Owner:
Type: | Amansingh1202
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 3.1
Severity: Normal | Resolution:
Keywords: media, uploads, | Triage Stage:
images, forms, MEDIA_URL, | Unreviewed
MEDIA_ROOT, tutorial |

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Amansingh1202):

* owner: nobody => Amansingh1202
* status: new => assigned


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

Django

unread,
Feb 4, 2021, 12:16:19 PM2/4/21
to django-...@googlegroups.com
#32419: MEDIA_URL and MEDIA_ROOT configuration ambiguous; suggested adjustment
-------------------------------------+-------------------------------------
Reporter: Josef Richter | Owner:
Type: | Amansingh1202
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 3.1
Severity: Normal | Resolution:
Keywords: media, uploads, | Triage Stage: Accepted
images, forms, MEDIA_URL, |
MEDIA_ROOT, tutorial |

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Amansingh1202):

* stage: Unreviewed => Accepted


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

Django

unread,
Feb 4, 2021, 6:38:10 PM2/4/21
to django-...@googlegroups.com
#32419: "Serving files uploaded by a user during development" example unclear about
"urls.py"
-------------------------------------+-------------------------------------
Reporter: Josef Richter | Owner: Amankumar
Type: | Singh

Cleanup/optimization | Status: assigned
Component: Documentation | Version: 3.1
Severity: Normal | Resolution:
Keywords: media, uploads, | Triage Stage: Accepted
images, forms, MEDIA_URL, |
MEDIA_ROOT, tutorial |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by 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.

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

Django

unread,
Feb 4, 2021, 10:59:58 PM2/4/21
to django-...@googlegroups.com
#32419: "Serving files uploaded by a user during development" example unclear about
"urls.py"
-------------------------------------+-------------------------------------
Reporter: Josef Richter | Owner: Amankumar
Type: | Singh
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 3.1
Severity: Normal | Resolution:
Keywords: media, uploads, | Triage Stage: Accepted
images, forms, MEDIA_URL, |
MEDIA_ROOT, tutorial |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Amankumar Singh):

* has_patch: 0 => 1


Comment:

https://github.com/django/django/pull/13978

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

Django

unread,
Feb 5, 2021, 9:34:23 AM2/5/21
to django-...@googlegroups.com
#32419: "Serving files uploaded by a user during development" example unclear about
"urls.py"
-------------------------------------+-------------------------------------
Reporter: Josef Richter | Owner: Amankumar
Type: | Singh
Cleanup/optimization | Status: closed
Component: Documentation | Version: 3.1
Severity: Normal | Resolution: fixed

Keywords: media, uploads, | Triage Stage: Accepted
images, forms, MEDIA_URL, |
MEDIA_ROOT, tutorial |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by GitHub <noreply@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"51637222b6eeed81d9ce6f5d24e22e249c605ba3" 51637222]:
{{{
#!CommitTicketReference repository=""
revision="51637222b6eeed81d9ce6f5d24e22e249c605ba3"
Fixed #32419 -- Clarified URLconf in example of serving media files.
}}}

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

Django

unread,
Feb 5, 2021, 9:34:51 AM2/5/21
to django-...@googlegroups.com
#32419: "Serving files uploaded by a user during development" example unclear about
"urls.py"
-------------------------------------+-------------------------------------
Reporter: Josef Richter | Owner: Amankumar
Type: | Singh
Cleanup/optimization | Status: closed
Component: Documentation | Version: 3.1
Severity: Normal | Resolution: fixed
Keywords: media, uploads, | Triage Stage: Accepted
images, forms, MEDIA_URL, |
MEDIA_ROOT, tutorial |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Josef Richter):

Replying to [comment:3 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.

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

Django

unread,
Feb 5, 2021, 9:34:54 AM2/5/21
to django-...@googlegroups.com
#32419: "Serving files uploaded by a user during development" example unclear about
"urls.py"
-------------------------------------+-------------------------------------
Reporter: Josef Richter | Owner: Amankumar
Type: | Singh
Cleanup/optimization | Status: closed
Component: Documentation | Version: 3.1
Severity: Normal | Resolution: fixed
Keywords: media, uploads, | Triage Stage: Accepted
images, forms, MEDIA_URL, |
MEDIA_ROOT, tutorial |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"d192d751e15f0573c9ebb16cf5173ab9c3ae3801" d192d751]:
{{{
#!CommitTicketReference repository=""
revision="d192d751e15f0573c9ebb16cf5173ab9c3ae3801"
[3.2.x] Fixed #32419 -- Clarified URLconf in example of serving media
files.

Backport of 51637222b6eeed81d9ce6f5d24e22e249c605ba3 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32419#comment:7>

Reply all
Reply to author
Forward
0 new messages