STATIC and MEDIA

40 views
Skip to first unread message

Jonathan Querubina

unread,
Mar 29, 2014, 7:39:41 PM3/29/14
to django...@googlegroups.com
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

unread,
Mar 30, 2014, 12:49:22 PM3/30/14
to django...@googlegroups.com
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,
--
Julio Molina Soler
julio....@telenet.be
Github: https://github.com/jmolinaso

John

unread,
Mar 30, 2014, 2:19:20 PM3/30/14
to django...@googlegroups.com
Hi Julio!

Thank u so much!

Jonathan
Diretor de Tecnologia
+55(12)98864-1594

Sent from my iPhone
> --
> 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...@googlegroups.com.
> To post to this group, send email to django...@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.
Reply all
Reply to author
Forward
0 new messages