Why django not found static files?

5,745 views
Skip to first unread message

Marc Aymerich

unread,
Feb 3, 2011, 6:51:26 AM2/3/11
to django...@googlegroups.com
Hi,
I just installed the django-admin-tools app but my django installation
doesn't load the css, js and other static files.

in settings.py I have:
STATIC_ROOT = '/home/ucp/trunk/static/'
STATIC_URL = '/static/'

and when i try to load
http://localhost:8081/static/admin_tools/css/dashboard.css I get a
"page not found" error :(

but this file seems to be in the right directory and have read
permisons for my user!
/home/ucp/trunk/static/admin_tools/css/dashboard.css

what I'm missing?

Thanks!
--
Marc

Marc Aymerich

unread,
Feb 3, 2011, 7:04:24 AM2/3/11
to django...@googlegroups.com


I solve it setting staticfiles_dirs var:

STATICFILES_DIRS = ('/home/ucp/trunk/static/',)


--
Marc

Brian Neal

unread,
Feb 3, 2011, 8:58:39 AM2/3/11
to Django users
On Feb 3, 6:04 am, Marc Aymerich <glicer...@gmail.com> wrote:
> On Thu, Feb 3, 2011 at 12:51 PM, Marc Aymerich <glicer...@gmail.com> wrote:
> > Hi,
> > I just installed the django-admin-tools app but my django installation
> > doesn't load the css, js and other static files.
>
> > in settings.py I have:
> > STATIC_ROOT = '/home/ucp/trunk/static/'
> > STATIC_URL = '/static/'
>
> > and when i try to load
> >http://localhost:8081/static/admin_tools/css/dashboard.cssI get a
> > "page not found" error :(
>
> > but this file seems to be in the right directory and have read
> > permisons for my user!
> > /home/ucp/trunk/static/admin_tools/css/dashboard.css
>
> > what I'm missing?
>
> I solve it setting staticfiles_dirs var:
>
> STATICFILES_DIRS = ('/home/ucp/trunk/static/',)
>

STATIC_ROOT is the location of where the management command is going
to place all the static files it collects. So normally (?) I think
you'll want STATIC_ROOT to be a different directory than what you put
in STATICFILES_DIRS. Think of it this way: your non-app specific
static files will appear in a directory that is listed in
STATICFILES_DIRS, your app-specifc files typically would appear under
your_app/static, and all of the static files will be copied to
STATIC_ROOT after running the management command. In production, you'd
likely configure your server to serve files out of STATIC_ROOT.

Hope that helps,

BN

Marc Aymerich

unread,
Feb 3, 2011, 9:13:47 AM2/3/11
to django...@googlegroups.com

Thanks Brian, now I understand what is STATIC_ROOT and STATICFILES_DIRS :)

--
Marc

Reply all
Reply to author
Forward
0 new messages