google-code-export / django-photologue

Automatically exported from code.google.com/p/django-photologue
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Media URL not being prepended #40

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Media URL not at root of domain
2. Media folder (inside "public_html") is a symbolic link back to
"public_html" folder.
3. nginx Web Server (location /media/: root is pointed to the "public_html"
folder)

What is the expected output? What do you see instead?
When you view an image, it does not give you the right URL. I would need to
prepend /media/ to the URL it produces to get the image.

What version of the product are you using? On what operating system?
1.0b. Ubuntu Gusty 7.10

Please provide any additional information below.
If I defined PHOTOLOGUE_DIR = "media/photologue", then it would produce
correct URLS.

Original issue reported on code.google.com by lilxviet...@gmail.com on 20 Mar 2008 at 5:58

GoogleCodeExporter commented 9 years ago
MEDIA_URL needs to be the public path to the location defined in MEDIA_ROOT. It
sounds like your MEDIA_URL is "www.mysite.com" and needs to be 
"www.mysite.com/media".

- Justin

Original comment by justin.d...@gmail.com on 21 Mar 2008 at 12:33

GoogleCodeExporter commented 9 years ago
I thought to double check,

Quoted from my settings.py

MEDIA_ROOT = '/var/www/mydomain.com/public/media/'
MEDIA_URL = 'http://mydomain.com/media'

Original comment by lilxviet...@gmail.com on 21 Mar 2008 at 5:29

GoogleCodeExporter commented 9 years ago
Are those the settings that are NOT working? Or did you get it fixed?

Original comment by justin.d...@gmail.com on 21 Mar 2008 at 5:40

GoogleCodeExporter commented 9 years ago
Not working.

I have to use:
PHOTOLOGUE_DIR = "media/photologue"
For it to work properly

Original comment by lilxviet...@gmail.com on 21 Mar 2008 at 6:00

GoogleCodeExporter commented 9 years ago
It should be:

MEDIA_ROOT = '/var/www/mydomain.com/public/media/'
MEDIA_URL = 'http://mydomain.com/media/'

Original comment by remigi...@gmail.com on 23 Mar 2008 at 9:07

GoogleCodeExporter commented 9 years ago
I replied to the issue notification last week but I don't think this was posted:

1. Can you upload photos and where are they being saved (the path)
2. if you copy a file to /var/www/mydomain.com/public/media/ is it viewable 
from 
http://www.mydomain.com/media/?
3. Why are you symlinking /public/media back to /public? Or have I 
misunderstood?

Original comment by justin.d...@gmail.com on 23 Mar 2008 at 9:24

GoogleCodeExporter commented 9 years ago
1. Uploads goto /var/www/mydomain.com/public/photologue/photos/...
2. If something is in /public/media/ it is viewable from domain.com/media.
3. The symlink is there for nginx (If I do a location /media/ and set the root 
to
/var/www/mydomain.com/public/, nginx will append a media/ folder). 

Original comment by lilxviet...@gmail.com on 24 Mar 2008 at 7:52

GoogleCodeExporter commented 9 years ago
What happens if you set your MEDIA_ROOT to 'var/www/mydomain.com/public/'. It 
sounds
to me like the symlink is creating a loop (I'm not on a *nix box right now to 
try it
out).

Original comment by justin.d...@gmail.com on 24 Mar 2008 at 8:05

GoogleCodeExporter commented 9 years ago
Ok, scratch that. Create a new file called test.txt in the public folder and 
then
open a python in your terminal and try this:

import os
print os.path.dirname('/var/www/mydomain.com/public/media/test.txt')

My guess is that it returns /var/www/mydomain.com/public/ instead of
/var/www/mydomain.com/public/media/. That would cause your issue as Photologue 
uses
os.path.dirname to get the parent folder of your image files to determine the 
path to
the cache directory and the because the file ISN'T actually in /media dirname is
returning the "wrong" directory... 

Why not just use a "real" media directory under public?

Original comment by justin.d...@gmail.com on 24 Mar 2008 at 8:13

GoogleCodeExporter commented 9 years ago
>>> import os
>>> print os.path.dirname('/var/www/mydomain.com/public/media/test.txt')
/var/www/mydomain.com/public/media

Interesting right?

Unfortunately for both of us, based on laziness, the main reason that the 
symlink is
there is because I didn't feel like moving/navigating through media every 
single time
I need to edit a file. I guess I could've set it up so that i could rename 
'public'
to 'media' and point my nginx /media/ root to /var/www/mydomain.com/. It's 
something
to think about next time when setting up a django project with nginx.

I wanted to repeat that I did find a solution by prepending 'media' to the
photologue_dir setting. With that, this issue was created just to see how 
photologue
gets its directory in case others could not find a solution to a problem like 
this.

Original comment by lilxviet...@gmail.com on 24 Mar 2008 at 9:24

GoogleCodeExporter commented 9 years ago
Well if this is working for you, I'm just going to mark this won't-fix. 

Original comment by justin.d...@gmail.com on 26 Mar 2008 at 11:33

GoogleCodeExporter commented 9 years ago
I am having a very similar problem. 
MEDIA_ROOT = '/home/wsd/webapps/django/wsd/assets'
MEDIA_URL='http://mydomain.com/assets'

File upload works fine, and I can access the uploaded images (e.g.
http://mydomain.com/assets/photologue/photos/2008/Apr/27/cache/test.jpg) but
generated urls to the images do not include the 'assets' portion of MEDIA_URL 
(e.g.
http://mydomain.com/photologue/photos/2008/Apr/27/cache/test.jpg).

>>> import os
>>> print os.path.dirname('/home/wsd/webapps/django/wsd/assets/test.txt')
/home/wsd/webapps/django/wsd/assets

I tried the solution proposed by lilxvietxboi, but when I prepend 'assets' to
PHOTOLOGUE_DIR setting, files were saved with nested 'assets' dirs
('/home/wsd/webapps/django/wsd/assets/assets/...') and the generated urls only 
had a
single 'assets' in the path, so image tags still broken.

I am using webfaction hosting, if that helps at all. Any suggestions would be
appreciated.

Original comment by chris.em...@gmail.com on 28 Apr 2008 at 3:57