Code

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#10054 closed (invalid)

Naming issue with static files in standard urlpattern

Reported by: thomas.m.magee@… Owned by: nobody
Component: Uncategorized Version: 1.0
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 am using Django 1.0.2.

The Django book suggests that django users put the following in their urlconf to support static files:

(r'site_media/(?P<path>.*)$', 'django.views.static.serve',

{'document_root': '/path/to/media'}),

In the development server this makes static resources accessible at http://127.0.0.1:8000/site_media/

And this works well. However, if you change "site_media" to "media" as follows:

(r'media/(?P<path>.*)$', 'django.views.static.serve',

{'document_root': '/path/to/media'}),

The django development server responds with a 404 error for all requests to http://127.0.0.1:8000/media/

Attachments (0)

Change History (2)

comment:1 Changed 5 years ago by kmtracey

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

"media" is the default used by ADMIN_MEDIA_PREFIX:

http://docs.djangoproject.com/en/dev/ref/settings/#admin-media-prefix

So if you want to use "media" for your site media, you need to also change ADMIN_MEDIA_PREFIX to something else -- you can't use the same prefix for both admin media and your own static files.

comment:2 Changed 5 years ago by anonymous

  • milestone post-1.0 deleted

Milestone post-1.0 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.