straight55b / app-engine-patch

Automatically exported from code.google.com/p/app-engine-patch
0 stars 0 forks source link

Can't view static image #109

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Check out the sample
2. Start a new app
3. Add an image to the media folder of the app
4. Run the server, or deploy.
5. Try access the image using http://<host><MEDIA_URL><appname>/<filename>

The image isn't shown. In production I get error message, such as:
Error: Not Found

The requested URL /media/content/website-header.gif was not found on this 
server.

Using app-engine-patch 1.0,  on OS X 10.4.

Original issue reported on code.google.com by dibauna...@gmail.com on 18 Mar 2009 at 9:37

GoogleCodeExporter commented 9 years ago
Thanks for the bug report! Did you add the app to your INSTALLED_APPS in 
settings?

Original comment by wkornew...@gmail.com on 18 Mar 2009 at 9:45

GoogleCodeExporter commented 9 years ago
BTW, do you use {{ MEDIA_URL }} in your templates or do you enter it manually? 
You
have to use MEDIA_URL in order to make this work. On the dev_appserver the 
MEDIA_URL
becomes /generated_media/media/.

Original comment by wkornew...@gmail.com on 18 Mar 2009 at 9:54

GoogleCodeExporter commented 9 years ago
I didn't define MEDIA_URL in my settings, coz MEDIA_VERSION is. Should I define 
it? If not, how can I access it in 
my views?

Original comment by dibauna...@gmail.com on 20 Mar 2009 at 9:31

GoogleCodeExporter commented 9 years ago
No, that's fine. But do you use {{ MEDIA_URL }} in your templates and is 
"content" in
your INSTALLED_APPS?

Original comment by wkornew...@gmail.com on 20 Mar 2009 at 9:37

GoogleCodeExporter commented 9 years ago
{{ MEDIA_URL }} yields nothing in my template, & of course content is listed in 
INSTALLED_APPS. I'll try upload 
the project.
Thanks.

Original comment by dibauna...@gmail.com on 22 Mar 2009 at 3:56

GoogleCodeExporter commented 9 years ago
You have to use {{ MEDIA_URL }}. For this to work you need to add a context 
processor:

TEMPLATE_CONTEXT_PROCESSORS = (
    ...
    'django.core.context_processors.media',
    ...
)

Also, you have to use either ragendja.template.render_to_response/_string or 
Django's
render_to_response/_string with RequestContext. Otherwise, context processors 
get
ignored.

Original comment by wkornew...@gmail.com on 22 Mar 2009 at 4:07

GoogleCodeExporter commented 9 years ago
Marking as invalid since you didn't use MEDIA_URL.

Original comment by wkornew...@gmail.com on 22 Mar 2009 at 7:26