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.

Reply via email to