Question about Media root

78 views
Skip to first unread message

PythonistL

unread,
Dec 27, 2005, 8:34:03 AM12/27/05
to Django users
Hi,
I setup Django with mod_Python and it works well except Media files(
images).

On my Apache running on XP, the ServerRoot is: "C:/Program
Files/Apache Group/Apache2"

The directory (on my XP) where I have images
is:"C:\Django\TEMPLATES\Static\"
(and it is outside the web server root.) So in Appache httpd.conf I
setup Alias
like this

Alias /Media/ "C:/Django/TEMPLATES/Static/"

in Django settings.py file I have
MEDIA_ROOT = "/Media/" # because of alias in httpd.conf
MEDIA_URL = "http://localhost:8080/Media/"

Is the settings.py correct?

How shall I setup directories for the uploading files?
I would like to use these absolute paths:

filepath = 'C:\\Django\\TEMPLATES\Static\\Uploaded\\'
filepathThumb = 'C:\\Django\\TEMPLATES\Static\\Uploaded\\Thumbnail\\'
filepathNormal = 'C:\\Django\\TEMPLATES\\Static\\Uploaded\\Normal\\'

Nebojša Đorđević - nesh

unread,
Dec 29, 2005, 4:12:33 AM12/29/05
to django...@googlegroups.com
On 2005-12-27, at 14:34 CET, PythonistL wrote:

> MEDIA_ROOT = "/Media/" # because of alias in httpd.conf
> MEDIA_URL = "http://localhost:8080/Media/"
> Is the settings.py correct?

No, MEDIA_ROOT is filesystem path and MEDIA_URL is URL path:

MEDIA_ROOT='C:/Django/TEMPLATES/Static/'
MEDIA_URL = '/Media/'


> How shall I setup directories for the uploading files?
> I would like to use these absolute paths:
>
> filepath = 'C:\\Django\\TEMPLATES\Static\\Uploaded\\'
> filepathThumb = 'C:\\Django\\TEMPLATES\Static\\Uploaded\\Thumbnail\\'
> filepathNormal = 'C:\\Django\\TEMPLATES\\Static\\Uploaded\\Normal\\'

For image fields use something like this:

foo = meta.ImageField(upload_to=os.path.join(MEDIA_ROOT, 'Uploaded'))

also, you can look at http://djangoutils.python-hosting.com/
(thumbnails) for ImageWithThumbnailField and thumbnail related filters.

---
Nebojša Đorđević - nesh
Studio Quattro - Niš - SCG

http://djnesh.blogspot.com/ | http://djnesh-django.blogspot.com/ |
http://djangoutils.python-hosting.com/
Registered Linux User 282159 [http://counter.li.org]

Reply all
Reply to author
Forward
0 new messages