Hi, I am trying to configure settings.py in Django 1.4, but the settings for my uploaded media and static files are wrong. Here is what I have:
How can I fix this in webfaction on django1.4? Thank you. asked 22 Apr '12, 20:29 Nick_B |
OK, the issue can be solved by applying the same kind of 'static only' application you have for the static media for the uploaded media. Note the url is the URL to the photo, and that visiting it renders a Django error that the path is not defined. We can bypass Django and make the media served from nginx with a 'symbolic link to static only' type application. Create the application and in the extra info use the path for the MEDIA_ROOT,
Than bind that application to '/media' with the website record. This should solve the problem and serve the media as fast as possible. Thanks for your help @johns. Still having problems serving both my static files and my uploaded media, unfortunately. I have set my settings.py as such:
I believe that I have configured both my static-only app (static) and symbolic link app (media) properly in my webfaction cpanel. If you visit this link you will witness both problems in action. My css rules are being passed to the browser in the header, but for some reason they aren't being followed. The uploaded media from the admin site, on the other hand, is not being displayed from (
Any help would be appreciated. Thank you.
(27 Apr '12, 06:15)
Nick_B
@Nick_B: Your CSS isn't working because it isn't valid CSS. You need to replace those parentheses with braces, eg change this...
... to this ...
Regarding your thumbnails, they weren't working because your "media" symlink app wasn't attached to your website. I've fixed that for you and the thumbnails are working now. Hope that helps!
(27 Apr '12, 15:35)
seanf
Awesome thanks @seanf. You answered all of my questions. Thanks for solving my rookie mistakes
(28 Apr '12, 20:24)
Nick_B
I just did that. Hope that helps!
(28 Apr '12, 20:33)
neeravk
|
It should be,
Note the extra depth for 'myproject'. You can also set up 'static only' applications to serve the media which is better since its faster. Documentation on how to set up 'static only' apps for your media is here. answered 22 Apr '12, 21:53 johns I would have to see the links and the site to see what the issue is, but you can normally see it if you view the browser source and look, its normally a missing backslash or something minor missing in the template. You may submit a support ticket if you would like us to take a look and do not want to submit the real URL here.
(23 Apr '12, 19:39)
johns
|
I was following this post to serve my media files through nginx but am not sure if the media is being served by nginx or not, how do I confirm that? Is there anything like collectstatic for media too? This is what I did- 1. created static-only app for static files - seems to be working fine 2. created symbolic app for media files - dont know how to check how media files are being served now but it seems all my media files were copied there. I think I'm doing it correctly but just wanted to confirm if you could check. My link is <username>.webfactional.com. Also, how do I enable caching of media files? Does nginx automatically does something or I need memchache or other app? answered 25 May '12, 13:18 nistha Check the root of one of the files, so say this was your file, domain.com/static/file.jpg Visit this URL, domain.com/static/ If it is nginx you will see a 403 nginx error, if its Apache you will see a Django error.
(25 May '12, 17:38)
johns
|
This may be a bit late, but check at: ALLOWED_HOSTS = [] in your setting.py. This should be something like: ['<username>.webfactional.com', ] This is necessary if DEBUG=False. This is not documented in webfaction, or at least I couldn't find it :-( answered 23 Jul '13, 22:04 Manuel This setting is not mandatory in Django 1.4 so is not the issue in this case. It only became mandatory in Django 1.5 as documented in the Django 1.5 release notes.
(23 Jul '13, 23:30)
waynek
|