WebFaction
Community site: login faq

During development my uploaded images are showing, but on production they are not. Here are the codes:

#settings.py
STATIC_ROOT = '/home/eakdev/webapps/my_static'
MEDIA_ROOT = '/home/eakdev/webapps/my_static/media'
MEDIA_URL = '/media/'

#urls.py When I add this during development my images are showing correctly
urlpatterns += staticfiles_urlpatterns()
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

#base.html
<img class="img-responsive" src="{{ project.preview.url }}" alt="">

After reading some of the questions related to this, I think the reason why its not working is that my code is using dev server to serve the media files, which is only good for development. What do i change so that it would work in production?

asked 02 May '14, 02:14

eakdev
1112
accept rate: 0%


As mentioned in your ticket, you need to serve your media directory on the /media url. First by creating an application of type "Symbolic link to static/cgi/php app" and entering the path to your media files. Then mount it on the website entry on /media

permanent link

answered 02 May '14, 14:46

bmeyer71 ♦♦
1.5k3613
accept rate: 33%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×909
×337
×52

question asked: 02 May '14, 02:14

question was seen: 5,211 times

last updated: 02 May '14, 14:46

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM