Posts tagged: WEB DEVELOPMENT

robots.txt via Django, in one line

A significant difference between developing Django sites versus static-HTML-based approaches (among which I count PHP and the like) is that static files, aka “media”, live in a dedicated spot. Sometimes you need a piece of static content to be available at a specific URL outside your media root. robots.txt for example. This can be done in pure Django (i.e. without even touching your Apache configuration), and is especially nice if your robots.

Django LogEntry to the rescue

If you use Django’s admin application, you’re familiar with its “Recent Actions” sidebar. It gives a simple summary of your latest edits, including clickable links to the relevant objects (not any ones you deleted, naturally, but ones you added or changed). It’s probably not something you look at very often, unless you do such intensive work in the admin that you lose track of things. Django stores that log data (via the admin’s LogEntry model) for all admin users, a fact which has caused me to repeatedly daydream about writing a custom view or two to display it.

Making your way from PHP to Python and Django

“I’m a PHP programmer and I want to check out this Django thing. What should I do?” I’ve been seeing this kind of question pop up more and more, and I have a few answers. First-hand experience as well as many conversations with developers online have led me to the same conclusion: the curious person behind such a question should be encouraged and assisted. (I’ll call that person “Pat” for the rest of the post, for convenience and conscientious gender-neutrality.

How not to advocate via Google Code

People sure are excited about the Google App Engine. Especially people who have some other favorite language besides Python. A significant number of the issue tracker items are of the form “Please add support for $MY_LANGUAGE”, where $MY_LANGUAGE might be VB.NET, C#, PHP, Java, Groovy, Ruby, Perl, etc. ad nauseam. I’m not going to comment on the language-wars aspect. But if you want your language supported (this goes for any issue in the tracker in fact), the thing to do is not to go to one of those issue pages and add a comment that consists of “+1”.

From PHP to Python

A former colleague from my days in print design (and a wonderfully loyal reader of my blog to boot) writes to ask whether he should learn Python. He’s a smart guy with a deep background in typography, publishing, and the Mac. He is not a programmer by trade, but has taught himself enough PHP to build a custom CMS for his newspaper. He writes: I’ve invested so much time in PHP, and am quite proficient now (not bad for it being more of an avocation), but I respect your opinion and for a long time have wondered about switching.
World's ugliest Django app

World's ugliest Django app

OK, this is an ugly hack. But also (possibly) cool if you’re into ugly hacks. I’ve written a small Python script that is a fully functional, self-contained, self-starting Django application. You don’t need to put it on your PYTHONPATH or set DJANGO_SETTINGS_MODULE. You don’t need a web server. It even creates some dummy content for you. I call it jngo.py – it’s somewhat compressed. The only prerequisites are a Unix-like operating system (i.

darcs on pair.com

Shared hosting is starting to feel pretty quaint in the face of cheap and easy virtualization, but I still have some clients who use it. While doing some maintenance work today on one client’s Pair.com account, I started to twitch when I realized I was about to make some changes without using version control. I checked for Bazaar, Mercurial, and darcs command-line binaries; only darcs was installed, luckily a fairly recent version (1.