Hello!

You need create a "static" folder in your project and inside in this folder
you create a "css" folder.
I use this configuration and works.

settings.py

import os.path

STATIC_ROOT = ''

# URL prefix for static files.
STATIC_URL = '/static/'
ADMIN_MEDIA_PREFIX = '/static/admin/'

TEMPLATE_DIRS = (
    os.path.join(os.path.dirname(__file__), 'templates'),
)

And call a css for example, in base.html in this way:

<link href="{{ STATIC_URL }}css/style.css" rel="stylesheet" type="text/css"
media="screen" />

Regards.



2011/4/25 Joakim Hove <joakim.h...@gmail.com>

> Hello,
>
> I have just started using the {{ STATIC_URL }} template tag to insert
> proper url's to static resources in my templates. To use this tag I
> need to create the context for rendering as RequestContext() instance,
> which takes the request as a parameter for the initialisation.
>
> In my code I have several methods attached to models which create a
> suitable context for rendering that model instance in a specfied way:
>
> class MyModel( models.Model ):
>    ....
>    ....
>
>    def create_xxx_context( self , **kwargs):
>         ....
>
>    def create_yyy_context( self, ,**kwargs):
>         ....
>
> (Maybe that is a horrific design in the first place ???).
>
>
> Anyway - the methods create_???_context() do not have natural access
> to the request object (and I am reluctant to pass that argument on) -
> so I was wondering if I could achieve exactly the same by just
> "manually" adding the context variable STATIC_URL like:
>
> from django.conf import settings
> ....
>
> def view(request, args):
>    context = .....
>    context["STATIC_URL"] = settings.STATIC_URL
>    return render_to_response( template , context )
>
> Or is there more magic to the {{ STATIC_URL }} tag when it comes as a
> RequestContext()?
>
>
> Joakim
>
> --
> 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+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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

Reply via email to