google-code-export / django-hotclub

Automatically exported from code.google.com/p/django-hotclub
MIT License
0 stars 0 forks source link

MEDIA_ROOT in settings.py ignored for document_root #136

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Modify MEDIA_ROOT with anything
2. Restart Pinax
3. Any change to MEDIA_ROOT appears to be ignored

What is the expected output? What do you see instead?

Changes to the MEDIA_ROOT variable appears to be ignored and this section
of the urls.py has that directory hardcoded:

{{{
if settings.SERVE_MEDIA:
   urlpatterns += patterns('',
       (r'^site_media/(?P<path>.*)$', 'django.views.static.serve',
           {'document_root': os.path.join(os.path.dirname(__file__),
"site_media")}),
   )
}}}

What version of the product are you using? On what operating system?
Mac 10.5.5 Pinax trunk r1283

Please provide any additional information below.
Comment from Brian Rosner on mailing list: "MEDIA_ROOT is used by any
FileField or ImageField. It is indeed used, but really should also be used
to map the documet_root"

Original issue reported on code.google.com by arocki...@gmail.com on 15 Dec 2008 at 4:23

GoogleCodeExporter commented 9 years ago

Original comment by bros...@gmail.com on 15 Dec 2008 at 5:51

GoogleCodeExporter commented 9 years ago
This issue makes it hard to customize Pinax with your own site_media directory 
stored
elsewhere unless you start hacking the urls.py file. So a correction to this 
defect
would be appreciated.

Original comment by pyDanny on 22 Jan 2009 at 5:09

GoogleCodeExporter commented 9 years ago
The way static files are served during development has changed since 
introducing the build_media command and a distinct 
view. document_root isn't required anymore.

The matching path could be set to MEDIA_URL[1:] assuming it would never be a 
full URL in development.

if settings.SERVE_MEDIA:
    urlpatterns += patterns('', 
        (r'^%s(?P<path>.*)$' % settings.MEDIA_URL[1:], 'misc.views.serve')
    )

But I think it's a bit ugly and hides the fact that serving static media with 
Django is in fact a makeshift solution. Hence I'll 
soon close this ticket as WontFix unless I get a storm of boos. What do you 
think?

Original comment by leidel on 1 Mar 2009 at 3:58

GoogleCodeExporter commented 9 years ago
I think we're crossing paths here (no pun intended :-)).  The problem is that
MEDIA_ROOT (not MEDIA_URL) is ignored by the urls.py file for all the projects. 
There
are two solutions, either use MEDIA_ROOT for static content or put a comments in
settings.py that MEDIA_ROOT does not affect what relative folder static media is
pulled from.  Either way is fine for me so that people don't change MEDIA_ROOT
expecting a change that won't happen.

I would say just add a comment to settings.py if you want to get close to a 
WONTFIX.

Original comment by arocki...@gmail.com on 2 Mar 2009 at 2:49

GoogleCodeExporter commented 9 years ago
MEDIA_ROOT isn't ignored. In trunk it actually is used by both, the build_media 
management command and its equivalent static file serving view for local 
development.

Original comment by leidel on 2 Mar 2009 at 3:20

GoogleCodeExporter commented 9 years ago
I've been sloppy with my use of MEDIA_ROOT and MEDIA_URL, I apologize. I'm still
updating my skillset from PHP to Python/Django.

--------

If one goes to this URL, one gets the logo image

http://127.0.0.1:8000/site_media/pinax/images/logo.png

If one changes MEDIA_URL in settings.py to "/images/", the following URL does 
not
work.  It is still the URL with site_media:

http://127.0.0.1:8000/images/pinax/images/logo.png

One has to modify the urls.py file directly to make the change:

pinax/projects/complete_project/urls.py:103-106
if settings.SERVE_MEDIA:
    urlpatterns += patterns('', 
        (r'^site_media/(?P<path>.*)$', 'misc.views.serve')
    )

To:

if settings.SERVE_MEDIA:
    urlpatterns += patterns('', 
        (r'^%s(?P<path>.*)$' % settings.MEDIA_URL, 'misc.views.serve')
    )

--------

I would propose making that change to urls.py and changing MEDIA_URL to 
'site_media/'
(without the leading slash in my example, or with it in yours). If somebody is 
using
a non-development server it won't matter, and if they are using the development
server, it makes it easy to make the change (for first time users).

Anyway, this is really a trivial problem - I'm fine with marking this as 
WONTFIX and
moving on.

Original comment by arocki...@gmail.com on 2 Mar 2009 at 3:49

GoogleCodeExporter commented 9 years ago
Leidal, can you WontFix this or set it to a milestone?

Original comment by pyDanny on 13 Mar 2009 at 4:13

GoogleCodeExporter commented 9 years ago

Original comment by leidel on 13 Mar 2009 at 4:25