Skip navigation

Category Archives: Uncategorized

I just read Joshua Jonah’s post about Limiting HTTP requests with Django.  The gist is that he’s starting to get worried about all the different <link rel='stylesheet'>‘s and <script src='/some/js'>‘s in his document <head>, and we all know that each of those generates a separate HTTP request which will slow down your page’s load time.

My technique uses a view that builds a JS/CSS file with Django. The CSS/JS files that are compiled like this should be stored in your templates directory instead of your static media folder so they are accessible to the view…

…This allows you to used [sic] Django template language in your CSS files.

And I had an ah-HA! moment.  Could this be the way to use variables in your CSS files?  Having a view that defines a bunch of colors:

def buildcss(request):
linkColor = ‘#999’
linkHoverColor = ‘blue’

and passing that into the template that generates your CSS

a {
color: {{ linkColor }};

a:hover {
color: {{ linkHoverColor }};

Now, you probably don’t want have Django performing doing this kind of work for every request, so you might want to cache the URL that generates your CSS.  And I’m not sure if there are other downsides to this I haven’t considered, but it’s interesting to think about.


I ran across this link at reddit, and finally decided to install google’s chrome browser. I’d heard all about how Chrome handled javascript so much better than anyone else, and balldroppings was the first site I ran across that actually made me want to try it out.  Suffice to say, chrome handled the load WAYY better than Firefox.

find . -exec grep -l "search term" {} \;

My boss showed me this nifty little one-liner a while ago.  I thought I’d better post it before it dissapeared off my white board.

Was installing Django on a webserver recently, and something bit me.  I kept getting the following error:

...snip a whole buncha stuff...
ImportError: No module named django.core.handlers.modpython

I’d installed Django into my home directory, but the user that the webserver runs as didn’t have read access to that location.  Problem was solved by putting Django into a place where apache could get at it.

So, I’m building my own Django-based CMS for kicks and giggles, and I’d gotten it to the point where I can upload an HTML formatted screenplay (exported from Celtx), parse out a ton of cruft that Celtx adds(thank-you to beautifulSoup) , and display it in nicely formatted HTML via CSS (thanks to John August for some of his ideas).  I wanted to be able to offer a way for readers to comment on the screenplay but was foiled in trying to implement Django’s built in comment app.  So, I decided to roll my own comment system.  I had it very nearly in place, save for one little bugaboo: I couldn’t figure out how to associate a comment with a screenplay.  So I turned to the ever present #django channel and asked for help.  Before I could blink, I had two super nice chaps lobbing suggestions at me faster than I could try them out.  They worked instantly.  Turns out, it was a simple thing, just something I wasn’t familiar with.  Anyways, kudos to the Django community.  They really make this experiment worthwhile.