On Jun 18, 2:50 pm, Chris DPS <
jasonyf...@gmail.com> wrote:
> Hi,
>
> I'm new to Django.
> I've read the doc:
http://docs.djangoproject.com/en/dev/howto/static-files/?from=olddocs
> which is about static files but still do not quite understand what to
> call everything and it isn't working
> On my development machine, I want to use this hack and not deal with
> other servers.
> Please help.
>
> here is my file structure:
>
> /mysite/ - has all the .py files
> /mysite/templates/ - has all the html templates
> /mysite/templates/path_media/ - has the CSS document and pictures
>
> Now, how should I modify this:
>
> (r'^site_media/(?P<path>.*)$', 'django.views.static.serve',
> {'document_root': '/path/to/media'})
>
> '/path/to/media' should be changed to what?
Mine looks like this:
from django.conf import settings
...
if settings.DEBUG:
urlpatterns += patterns('',
(r'^static/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),
)
>
> And is this what I want for my style href? :
>
> <link type="text/css" href="site_media/style.css"
Read up on RequestContext. If you use that in conjunction with the
media context processor, then you can do this in your templates:
<link type="text/css" href="{{ MEDIA_ROOT }}style.css" />
http://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-context-processors-media
>
> What about when I pull an image using the css document:
>
> url("site_media/foo.jpg")
Paths inside CSS files are relative to the CSS files themselves. I
typically use relative paths inside CSS files, e.g.
url("../images/foo.jpg")
Best,
BN