Re: Multiple static media roots?

2009-01-26 Thread Malcolm Tredinnick

On Sat, 2009-01-24 at 10:09 -0800, John Baker wrote:
> OK thanks and yes it does but that's half the story. I haven't made
> myself very clear. The ImageField still tries to append /media/ to the
> image upload_to path rather than /uploads/ which would retrieve them
> from the dynamic media root rather than the application media.
> 
> My point was how do I get these 2 things to work together serving
> multiple media directories and FileFields?
> 
> The only way I can see is to have uploads under media which I don't
> really want. I can't see a way in the docs to tell file field which
> media root it belongs to.

I still don't think you've explained the problem you're having here.
ImageField and FileField using the upload_to path (and the MEDIA_ROOT
setting) to determine where to store things.

However, you can serve static media from anywhere you like. The
MEDIA_URL setting is used for uploaded media (stuff that is stored under
MEDIA_ROOT), since there's code inside django that uses MEDIA_ROOT for
file reading/write and MEDIA_URL for the URL of those resources. But
that doesn't mean you can't also have static stuff under any other URL
you like. You just need to use a different setting to refer to it.

The only reason Django has the MEDIA_URL setting is because it's a
necessary half of allowing file uploads. It's not required to put all
static media under that URL prefix.

So what is the difficulty here? What is the problem with referring to
your unchanging (non-uploaded) static content in templates, whether via
a string in the source somewhere, or using a different settings variable
of your own naming? Is it conceptual: you're trying to do everything
using MEDIA_URL?

Regards,
Malcolm


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multiple static media roots?

2009-01-24 Thread John Baker

OK thanks and yes it does but that's half the story. I haven't made
myself very clear. The ImageField still tries to append /media/ to the
image upload_to path rather than /uploads/ which would retrieve them
from the dynamic media root rather than the application media.

My point was how do I get these 2 things to work together serving
multiple media directories and FileFields?

The only way I can see is to have uploads under media which I don't
really want. I can't see a way in the docs to tell file field which
media root it belongs to.

>
> Er, yes it does. For example:
> (r'^site_media/(?P.*)$', 'django.views.static.serve',
>         {'document_root': '/path/to/media'}),
> (r'^uploads/(?P.*)$', 'django.views.static.serve',
>         {'document_root': '/path/to/uploads'}),
>
> In both cases, /path/to/whatever can be anywhere you like, and you can
> have as many as you want.
>
> Seehttp://docs.djangoproject.com/en/dev/howto/static-files/
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multiple static media roots?

2009-01-24 Thread Daniel Roseman

On Jan 24, 2:43 pm, John Baker  wrote:
> > write a custom file 
> > storagehttp://docs.djangoproject.com/en/dev/topics/files/
>
> Thanks. However, I know I can store them somewhere else but my problem
> is serving them up again in the local development environment. The
> django.views.static.serve doesn't take an argument for serving from a
> different system directory so its difficult to have 2.

Er, yes it does. For example:
(r'^site_media/(?P.*)$', 'django.views.static.serve',
{'document_root': '/path/to/media'}),
(r'^uploads/(?P.*)$', 'django.views.static.serve',
{'document_root': '/path/to/uploads'}),

In both cases, /path/to/whatever can be anywhere you like, and you can
have as many as you want.

See http://docs.djangoproject.com/en/dev/howto/static-files/
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multiple static media roots?

2009-01-24 Thread John Baker


> write a custom file storagehttp://docs.djangoproject.com/en/dev/topics/files/

Thanks. However, I know I can store them somewhere else but my problem
is serving them up again in the local development environment. The
django.views.static.serve doesn't take an argument for serving from a
different system directory so its difficult to have 2.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multiple static media roots?

2009-01-24 Thread Kenneth Gonsalves

On Saturday 24 Jan 2009 6:59:57 pm John Baker wrote:
> I need to separate static media roots into "static" (belonging to
> application - css, images etc) and "dynamic" (uploaded by users with
> filefields etc).
>
> The point is that truly "static" media doesn't change and is part of
> the deployed code. Dynamic "static" media is uploaded and kept in a
> separate directory not within the application code.

I have 2 - one is the standard media directory where users upload files and is 
outside the project directory, the other I call sitemedia which is a 
directory under the the project directory with three directories under it - 
css, js and images. This is mapped in apache conf to 
http://myproject.com/sitemedia/ - and it is referred to as /sitemedia/ in the 
templates. This sitemedia directory is also under version control as part of 
the site.

-- 
regards
KG
http://lawgon.livejournal.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multiple static media roots?

2009-01-24 Thread Raffaele Salmaso

John Baker wrote:
> Any suggestions?
write a custom file storage
http://docs.djangoproject.com/en/dev/topics/files/

-- 
()_() | That said, I didn't actually _test_ my patch.  | +
(o.o) | That's what users are for! | +---+
'm m' |   (Linus Torvalds) |  O  |
(___) |  raffaele at salmaso punto org |

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---