Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 Dec. 6, 2010 12:33:45

Jonas G.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

css templates


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-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 Dec. 6, 2010 13:01:56

Shamail T.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

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-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#3 Dec. 6, 2010 13:39:19

h.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

css templates


Here you find a page about serving multiple templates on the same site
(and saving the preference in a session):http://www.packtpub.com/article/multiple-templates-in-django--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

Board footer

Moderator control

Enjoy the 18th of August
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support