Re: css templates
Hi,
Well here is an approach, you can use the Django's template engine
for generating dynamic CSS as well...
lets assume your templates path is TEMPLATES
Now create a (minimal) file called style.css in your TEMPLATES like
this:
h1 {
font-size: {{font_size}};
text-decoration: {{text_decoration}};
}
Now create a view say, servestylesheet, map it like this:
(r'^css/(\d+).css$', servestylesheet)
In your view:
theme1 = {
'font_size' : "12px",
'text_decoration": "none",
}
theme2 = {
'font_size' : "15px",
'text_decoration": "underline",
}
# optionally use cache decorators here if you want to cache the CSS as
well, to avoid overloading
def servestylesheet ( request, css_code ):
if css_code == 1:
renderas = theme1 # Load theme from where ever you desire
else:
renderas = theme2
return render_to_response ( "style.css", renderas, "text/css" )
----
finally in your HTML, link to this stylesheet as:
<link rel="stylesheet" src="/css/1.css" type="text/css"
media="screen" />
or in general
<link rel="stylesheet" src="/css/{{using_theme}}.css" type="text/css"
media="screen" />
This is a one way, I hope community has more and better ways of doing
this..
Thanks
On Dec 6, 5:33 pm, Jonas Geiregat <jo...@geiregat.org> wrote:
> Hello,
>
> I'm developing a application that has the ability to be viewed with two stylesheets.
> There are some differences between the stylesheets. It's not only a different CSS file that is loaded but some pages also have different HTML output.
> How could something like this be implemented within the django framework ?
>
> Met vriendelijke groeten,
>
> Jonas Geiregat
> jo...@geiregat.org
--
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.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home