WebFaction
Community site: login faq

I'm having trouble serving media with my pinax site. I have the app in webapps/pinax_server/projects/social, I can get the site running and admin section shows media and css but not the main site.

I've followed the setup instructions here: http://code-old.pinaxproject.com/wiki/DetailedPinaxWebfaction/

I couldn't follow the media instructions as it doesn't let me mkdir in webapps. Also build_media is a deprecated command.

And I've set up static_media app and modified settings.py as in normal Django installation instructions provided by Webfaction. http://docs.webfaction.com/software/django/getting-started.html#getting-started-screencast

Is there any other tutorial that would explain how to modify settings.py and what to do in order for Pinax projects to have media.

asked 04 Aug '11, 08:12

kaarm
111
accept rate: 0%


Hi,

I looked at the instructions at http://code-old.pinaxproject.com/wiki/DetailedPinaxWebfaction/, and I'm assuming you are having a problem executing the following command:

mkdir ~/webapps/pinax_static/myproject

To do so, you should first create a "Static only" app and name it pinax_static - you will then be able to mkdir the myproject directory under the already existing pinax_static. Perhaps you can use the static_media app for this purpose and substitute it in the mkdir command.

I don't believe there is anything else you need to do. Editing settings.py should be standard, as you suggested. Frankly, I can't tell what's wrong with your installation without looking at it, so I would suggest that you open a ticket about it.

Regards,

Todor K

permanent link

answered 04 Aug '11, 09:48

todork
1.2k5
accept rate: 34%

You should be able to do mkdir in your 'webapps/pinax_server/projects/social' directory.

1) Following Pinax's conventions, make both 'media' and 'site_media' directories in your project ('social') directory, then inside 'site_media', make additional 'media' and 'static' directories.

The 'media' folder in your project root ('social') is the master repository for your project media. Every css, js, and image file that isn't already provided by a third-party app should be stored here. The staticfiles app will copy (or symlink) media from 'social/media' (as well as Django's admin media folder and other third-party app media) into 'social/site_media/static' when you run 'python manage.py collectstatic'.

The 'social/site_media/media' folder is used for media uploaded by users of your site. It's kept in it's own folder just for organization purposes. It should stay empty until you configure user uploads.

2) Make a 'Static only (no .htaccess)' webapp in the Webfaction control panel, we'll call it 'pinax_static' for example. Sounds like you already did this, but if you didn't type 'expires max' (no quotes) in Extra info when creating the static app, I'd recommend deleting it and doing it that way for browser optimization.

3) SSH to your server and make symlinks like this:

ln -sd ~/webapps/pinax_server/projects/social/site_media/static ~/webapps/pinax_static/static
ln -sd ~/webapps/pinax_server/projects/social/site_media/media ~/webapps/pinax_static/media

4) Add this new app to your Website entry in the Webfaction control panel, setting the URL path to '/site_media' (no quotes).

5) Make any changes needed to settings.py, here is mine for reference:

PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))

MEDIA_ROOT = os.path.join(PROJECT_ROOT, "site_media", "media")
MEDIA_URL = "/site_media/media/"

STATIC_ROOT = os.path.join(PROJECT_ROOT, "site_media", "static")
STATIC_URL = "/site_media/static/"

STATICFILES_FINDERS = (
'staticfiles.finders.FileSystemFinder',
'staticfiles.finders.AppDirectoriesFinder',
'compressor.finders.CompressorFinder', # only needed if you're using django-compressor
)

STATICFILES_DIRS = [
    os.path.join(PROJECT_ROOT, "media"),
    os.path.join(PINAX_ROOT, "media", PINAX_THEME),
]

ADMIN_MEDIA_PREFIX = posixpath.join(STATIC_URL, "admin/")

# Additional directories which hold static files
STATICFILES_DIRS = [
    os.path.join(PROJECT_ROOT, "media"),
    os.path.join(PINAX_ROOT, "media", PINAX_THEME),
]

6) Run 'python manage.py collectstatic --link' to make a ton of symlinks in 'social/site_media/static' to all the media files that are being watched by the staticfiles app. I think you would substitute 'build_static' for 'collectstatic' if you are sticking with the old version of the staticfiles app that comes with Pinax.

permanent link

answered 05 Aug '11, 05:04

swiharta
38159
accept rate: 33%

edited 05 Aug '11, 05:24

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:

×26
×13

question asked: 04 Aug '11, 08:12

question was seen: 3,710 times

last updated: 05 Aug '11, 05:24

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2020 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