Monday, September 26, 2011

Re: can't get STATICFILES to work (Django dev version)

Hi,

Using a static directory like that on the development server sounds wrong and you'll most probably have issues when the site goes live.

From what you said, it looks like you are confusing STATICFILES_DIRS and STATICFILES_ROOT.

Regards,
Xavier.


Le 27 sept. 2011 à 05:29, nara a écrit :

Good news, my static files finally work. (I wanted to make
one last try before giving up). Bottom line, I did not
have to make any changes to my original settings.py or urls.py.
All I did: created a static dir. under my app's directory, placed
the css files under it, and put '/static/css/blueprint/screen.css' to
refer to the external css. That was it.

Here is the head section of my template file, list.html:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 <link rel="stylesheet" href="/static/css/blueprint/screen.css"
type="text/css" media="screen, projection">
 <link rel="stylesheet" href="/static/css/blueprint/print.css"
type="text/css" media="print">
 <!--[if lt IE 8]>
   <link rel="stylesheet" href="/static/css/blueprint/ie.css"
type="text/css" media="screen, projection">
 <![endif]-->


Thanks
Nara

On Sep 26, 6:02 pm, nara <nar...@gmail.com> wrote:
Xavier,

I followed the blog, and at the end, my css files were not getting
pulled in.
I then tried doing a ./manage.py collectstatic, and this does collect
all
static files. Unfortunately, running the server still does not serve
my
css files.

I have spent too many cycles on this issue now. I will go back to my
workaround of just placing css inline in the templates, and later,
use Apache on my local machine to serve the css files.

Thanks
Nara

On Sep 25, 2:44 pm, Xavier Ordoquy <xordo...@linovia.com> wrote:







Hi,

I have read and followed the docs on static files.
django.contrib.staticfiles is in INSTALLED_APPS
(by default), and I have set STATICFILES_DIRS to where my static files
are (/home/nara/media). (I have
tried with and without a slash at the end of this absolute file path).

Static files aren't media. You should keep them separated.

I am confused about whether ./manage.py collectstatic is a necessary
step for static files to work, I didn't think so, and have not done
that.

It isn't if you aren't on production stage (ie, DEBUG=False).

I have started a post on how to setup static files. It isn't finished yet but might help you to set it up:http://www.linovia.com/blog/django-staticfiles-howto/

Regards,
Xavier.

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.


No comments:

Post a Comment