Sunday, March 30, 2014

Re: STATIC and MEDIA

Hi Jonathan,

the cleanest way I found:

at the beginning of your settings.py add

import os
BASE_PROJECT = os.path.dirname(__file__)

then when the section comes

MEDIA_ROOT = os.path.join(BASE_PROJECT,'media')
MEDIA_URL = '/media/'

STATIC_ROOT = os.path.join(BASE_PROJECT,'static')
STATIC_URL = '/static/'

and in some cases I also add the static inside the apps like this

STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or
"C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
os.path.join(BASE_PROJECT, 'newApp','static')
)

Julio,

On dom 30 mar 2014 00:39:41 CET, Jonathan Querubina wrote:
> Guys
>
> What is the best way to configure and make accessible via URL the STATIC and the MEDIA uri?
>
> I can`t seem to find a good way, and get so many errors for the both being equal.
>
> Can someone send me an example of this configs?
>
> Thanks!
>



--
Julio Molina Soler
julio.molina@telenet.be
Github: https://github.com/jmolinaso

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/53384B12.3050202%40telenet.be.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment