How to setup custom CSS based on account settings in a Django site?

Posted by sdolan on Stack Overflow See other posts from Stack Overflow or by sdolan
Published on 2010-06-17T03:18:54Z Indexed on 2010/06/17 3:23 UTC
Read the original article Hit count: 158

Filed under:
|
|
|

So I'm writing a Django based website that allows users select a color scheme through an administration interface.

I already have middleware/context processors that links the current request (based on domain) to the account.

My question is how to dynamically serve the CSS with the account's custom color scheme.

I see two options:

  1. Add a CSS block to the base template that overrides the styles w/variables passed in through a context processors.

  2. Use a custom URL (e.g. "/static/dynamic/css//styles.css") that gets routed to a view that grabs all the necessary values and creates the css file.

I'm content with either option, but was wondering if anyone else out there has dealt with similar problems and could give some insight as to "Best Practices".

© Stack Overflow or respective owner

Related posts about css

Related posts about best-practices