Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8256637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:55:04+00:00 2026-06-08T01:55:04+00:00

Having written a lot of python before I’m quite new to django, and loving

  • 0

Having written a lot of python before I’m quite new to django, and loving it so far.

My previous web experience is in PHP and in order to make my CSS easy to maintain I use a php file as my CSS and serve it as CSS content-type. Therefore I can make variables which can easily be changed to make everything in the site change.

e.g. styles.php:

<?php header('Content-type: text/css');

$pink = '#91305f';
$green = '#a4ce39';
$black = '#000000';
$white = '#ffffff';
$std_font = "'Ruda', sans-serif";
$std_shadow = "text-shadow: 1px 1px 1px #000;";
$big_shadow = "text-shadow: 2px 2px 2px #000;";
$h_space = '10px';
?>

and…

html {
    background-color:<?= $pink ?>;
    color: <?= $green ?>;
    font-family: <?= $std_font ?>;
}

so if I want to change what black means in my whole site, I just alter the $black = at the top and all places in my CSS where I’ve said color: ; will follow.

I want to achieve the same type of thing in django but can’t figure out how to do it. I’m thinking I could use a view to render a template in css but not really sure how to go about this. Is it as simple as creating a dict in my view and passing it to render_to_response then referring to it in my template file?

e.g. views.py:

def style(request):
    colours = {'pink' : '#91305f', 'green' : '#a4ce39'}
    return render_to_response('styles.css', {'styles': colours},
                              context_instance=RequestContext(request))

then, in templates/styles.css:

html {
        background-color:{{ styles.pink }};
        color: {{ styles.green }};
    }

Is this a viable solution? If so, it seems like I am coupling the view to the template but I can’t figure out where I would otherwise store the data needed to achieve this.

Thanks
Aaron

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T01:55:06+00:00Added an answer on June 8, 2026 at 1:55 am

    If I understand your question correctly you want to be able to easily change the layout for your whole site, without editing alle your stylesheets. To me it sounds like you don’t want to use inline styles and generated css, but instead use either SASS or LESS and use the variables to design the colors:

    • http://sass-lang.com/
    • http://lesscss.org/
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been developing a web application (written in Python/Django) for a while. All my
I'm fairly new to EJBs and full blown application servers like JBoss, having written
I'm having trouble with a query written in LINQ and Lambda. So far, I'm
I am new to both Python (and django) - but not to programming. I
I'm often having code written as follows try: self.title = item.title().content.string except AttributeError, e:
I am having difficulty creating sessions for my mobile application that is written in
I'm having a problem with some code I've written. I've had to anonymize it,
Hi guys i've never written a comparator b4 and im having a real problem.
I am having my webservice for my mobile app which written using JAVA. I
I have written a SQL query that works just fine, but am having a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.