Opened 5 years ago

Closed 5 years ago

#13151 closed (wontfix)

If ADMIN_MEDIA_PREFIX is not assigned, things don't work...documentation should be updated

Reported by: mlissner@… Owned by: nobody
Component: Documentation Version: 1.1
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

I just spent about 45 minutes trying to get the instructions here to work: http://docs.djangoproject.com/en/dev/howto/static-files/

Turns out, the only reason they didn't work was because I didn't have anything set for ADMIN_MEDIA_PREFIX. I don't think I ever deleted this from my settings file...I might have, I don't know, but by adding:

ADMIN_MEDIA_PREFIX = "/path/to/wherever/that/does/not/even/exist/"

I was able to get everything to work. Just by putting a value in there. I am new to django, but if the documentation said this, it would make life much easier. It does warn about having ADMIN_MEDIA_PREFIX be the same as another value, so adding this kind of warning makes sense to me, at least in theory.

Change History (5)

comment:1 Changed 5 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

When you start a new project, ADMIN_MEDIA_PREFIX is included in the stub settings file, and set to '/media/'. If you delete this line, it falls back to the default value, which is also '/media/'. The documentation you reference says that your value for ADMIN_MEDIA_PREFIX will default to '/media/', but it mustn't clash with the URL you choose for your site media.

What exactly do you want us to clarify? If you don't have a valid ADMIN_MEDIA_PREFIX, you won't be able to use the admin site, so suggesting ADMIN_MEDIA_PREFIX = "/path/to/wherever/that/does/not/even/exist/" isn't a good idea.

Marking wontfix; if you can clarify exactly what needs improving, please reopen.

comment:2 Changed 5 years ago by mlissner

  • Resolution wontfix deleted
  • Status changed from closed to reopened

Sorry if that was vague, umm, my suggestion is to note that if ADMIN_MEDIA_PREFIX isn't present in settings.py, that it will default to /media/, which will cause things not to work in certain cases. When it doesn't work, the error message is TOTALLY vague, giving only permission denied messages, even for folders that don't exist.

I believe that without ADMIN_MEDIA_PREFIX you CAN use the admin site, and you can even do so with it set to something crazy, as I have above, if you are using runserver, as I am on my development machine.

comment:3 Changed 5 years ago by russellm

  • Resolution set to wontfix
  • Status changed from reopened to closed

How is this requirement not met by the phrase:

Be careful not to use the same path as your ADMIN_MEDIA_PREFIX (which defaults to /media/) as this will overwrite your URLconf entry.

To my reading, this statement is *exactly* what you're asking for us to add, and it's already there in the text.

comment:4 Changed 5 years ago by mlissner

  • Resolution wontfix deleted
  • Status changed from closed to reopened

It's not met b/c the documentation doesn't say that if the variable isn't set, that it defaults to /media/. In my case, I didn't have the variable (no idea why), and therefore things didn't work. It's a leap to go from the sentence that's there to the realization that not having the variable set will cause permission denied errors. Perhaps a reasonable (and minor) change would be to change this sentence:

"Be careful not to use the same path as your ADMIN_MEDIA_PREFIX (which defaults to /media/) as this will overwrite your URLconf entry."

To:
"Be careful not to use the same path as your ADMIN_MEDIA_PREFIX (which defaults to /media/ if it is not set) as this will overwrite your URLconf entry."

I guess in hindsight, I see that the sentence above clarifies the issue I was having, but checking google does indicate that I'm not alone in this:
http://www.google.com/search?hl=en&hs=ebV&q=admin_media_prefix+%22permission+denied%22

comment:5 Changed 5 years ago by kmtracey

  • Resolution set to wontfix
  • Status changed from reopened to closed

That's what a default is: the value that is assigned to a variable if you don't set the variable to something else. Adding "if it is not set" in the doc cited above is redundant and odd-sounding (to me).

Personally I think it is unfortunate that the default value for ADMIN_MEDIA_PREFIX was chosen to be a value that has such high likelihood of matching what many would most naturally choose for other site media. I think it is that choice that is responsible for many having been bit by this. The doc does attempt to warn (and it does a better job than it used to, if you read a bit in those Google results you point to you will see that), but given the unfortunate choice of admin default here I don't think any amount of doc will entirely cure the problem. (And changing the default is a battle already waged and lost in another ticket -- if it didn't manage to get done before 1.0, due to concerns about the change breaking already-running sites, I don't see it happening now.)

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