Posted in 2009
Correct way to handle default model fields.
- Nov 22 2009
With Kong, I have been trying to figure out a way to provide
overridden model defaults. At work, our pythonpath’s default to
/home/code
, however your setup is probably different. It would
be useful if there was a simple way to let you override the
defaults for your Kong installation.
Writing Code with Designers
- Nov 19 2009
When working on side projects, usually you wear all of the hats. Sysadmin, developer, designer, marketing, etc. You have to do all of them, and presumably you do one or two of them well, and the others well enough to get by. Working at the Journal World has been the first time that I have worked with real designers, and it has been a learning experience.
Finding Missing Indexes That Django Wants (Postgres)
- Nov 18 2009
On Monday at work, our sites started to slow to a crawl. We looked to diagnose the problem, and found that the database server had a load of 10, and was struggling to keep up with the morning rush of traffic. After EXPLAINing the slow queries from the slow query log, we noticed that a lot of sequence scans were happening. This shouldn’t be happening because these queries should have indexes on them. We realized somewhere in the porting process that we had lost a bunch of indexes.
Announcing Kong: A server description and deployment testing tool
- Nov 17 2009
At work we have to manage a ton of Django based sites. Just for our World Company sites, we have over 50 different settings files, and this doesn’t take into account the sites that we host for other clients. At this size it becomes basically impossible to test each site in a browser when you push things to production. To solve this problem I have written a very basic server description tool. This allows you to describe sites (settings file, python path, url, etc.) and servers.
You should stay for the sprints
- Nov 16 2009
At most open source conferences, a lot of attention is given to the talks. At the ones that I have been to (Djangocon and Pycon), the most fun that I have had, and the most I have learned is during the sprints. I want to talk about the value and importance of staying for the sprints at a conference.
Django Testing Code Coverage
- Nov 13 2009
As part of the summer of code 2009, Django test coverage has been developed. I mentored Kevin Kusabik, who developed the code. It is hopefully going to be merged in 1.2, but there are still a few issues to be worked out in the implementation. That said, it currently works, and provides a nice introspective view of your code. This post will tell you how to run coverage on your code base.
The importance of striving for awesome.
- Nov 12 2009
When I was about to graduate from college, I was often asked what I would be doing with the rest of my life. This is a usual question that is asked of graduates and I have very rarely heard it answered to satisfaction. Upon being asked this for the 42nd time, I decided on my response..”Something Awesome”
Large Problems in Django, Mostly Solved: APIs
- Nov 11 2009
This is the third part of my Large Problems Series. The first two were Search and Database Migrations.
Correct way to handle mobile browsers
- Nov 09 2009
At work, a lot of our sites have sweet mobile versions. The problem is how to educate people of their existence. Currently we just have little ads that show up on the site that promote the mobile site, which seems a subpar solution. So I was tasked with doing providing a way to redirect to the mobile sites. Luckily, as a lot of the time with Django, most of my work was done for me.
Large Problems in Django, Mostly Solved: Database Migrations
- Nov 06 2009
Continuing in the series of big problems that are mostly solved, we have database migrations. A couple days ago I talked about Search.
Adding testing to pip
- Nov 05 2009
Python packaging has been in a bit of a state of disarray for as long as I’ve been using it. Pip has come along to make installing python packages easier. It has a lot of features that are useful, but they have been talked about in many other blog posts.
Making Template Tag Parsing Easier
- Nov 03 2009
In my previous post about template tags, I discussed the two steps required for template tags. Today I will be focusing on Parsing of template tags, and how they may be improved in the framework of Class Based Template Tags from yesterday. I have talked about problems with template parsing in the past as well. This post will offer 2 different approaches to making parsing better.
Class Based Template Tags
- Nov 03 2009
In Django, template tags currently are separated between a Node class and a “parsing function”. The parsing function takes the tag, represented as a string, parses the input, and passes the correct arguments to a Node class. The Node class then does whatever rendering it does, or updating of the context, and then renders itself in a form suitable for the template.
Large Problems in Django, Mostly Solved: Search
- Nov 02 2009
It’s been a little over a year since I started doing Django development full-time, for one of them real jobs. Around that time, there were a few large problems in the community that hadn’t been solved yet. They were kind of blemishes when you would talk to people about Django, and I’m happy that most of them have been solved.
Easily Running the Django Test Suite
- Oct 15 2009
Update As of Django 1.2, Django ships with default test settings for sqlite. They require two databases to be defined, because of Multidb. More information at Django advent and in the docs
Hacker Book Club
- Sep 26 2009
At LPDN, our weekly programmer drinkup, we have been talking for a while about watching the SICP lectures from MIT as a fun thing to do. I then got to thinking about how it would be neat to involve more than just the few of us in Lawrence. Everything is more fun on a larger scale, and having compatriots makes you more likely to finish it. Somewhere along the lines of the Infinite Summer, I was thinking about having some kind of Hacker Book Club.
Pretty Django Error Pages
- Sep 23 2009
Continuing on with the simple tricks that make everyone’s life a little bit better, I know a lot of people hate that Django’s 500 pages don’t get rendered as a RequestContext. This means that if you have context processors (like one that sets a MEDIA_URL), they don’t get called. This was causing our 500 pages not only to make users sad because something broke, but knock them out of context becaue our entire design blew up.
Token Testing Talk Slides: Djangocon 2009
- Sep 08 2009
There are the slides to my Token Testing Talk from Djangocon. I’m hoping the videos will be posted soon, but I think that it went well. There were a lot of good questions, and I need to put some recap posts up, but for now here is a copy of the slides. PDF
Debugging Django in Production Revisited
- Sep 05 2009
In a previous post I talked about a neat middleware to debug production environments in Django. It basically checked to see if you were a superuser, or if you were in settings.INTERNAL_IPS, and if so, then it displayed a technical 500 page for you (The yellow one you know and love). Anyway, at that point it was more of a simple idea, and not really used in production.
Enable setup.py test in your Django apps
- Jun 29 2009
Setuptools comes with a way to
run the tests on your application.
This allows the user of your software to download it, and run
python setup.py test
and check to see if the tests in your
application pass. This is really useful for distribution, because
the user doesn’t need to know or care how to run your tests (nose,
django, unittest, py.test, or whatever else), and can simply see if
they pass.
Migrating Django Test Fixtures Using South
- Jun 11 2009
Migrating test fixtures is one of the biggest pains of testing. If you create your tests too early, then change your schema, you have to go back and touch all your old test fixtures. This discourages people from writing tests until their app is relatively ‘stable’. As we all know, this may never happen :) This solves half of the problem, the part where you have to manually change a bunch of fixtures to reflect changes in your schema or data.
A playground for Django Template tags and filters
- May 24 2009
Any sufficiently large Django project starts to have a wide variety of Template Tags and Filters. Even Django ships with a dizzying array of them that allow you to do all sorts of fun and interesting things. Ellington, our CMS at work, has a ton, and I’ve been thinking about ways to make tags and filters a bit more accessible to people who are using the CMS.
EuroDjangoCon Talk: Testing Django
- May 05 2009
Just got off the stage at EuroDjangocon, which was my first real talk in front of the Django Community. I hope that people enjoyed it, and that it was informational. Here are the slides to my talk in PDF Form, and on slideshare.
Django’s Summer of Code students announced!
- Apr 20 2009
Today is the day that Google has announced the accepted projects for the Summer of Code. Django has 6 spots this year, with a bunch of exciting projects. I am lucky enough to be mentoring Kevin Kubasik with his project “Upgrade the Awesomness Quotient of the Django Test Utils and Regression Suite”. I’m really excited for the opportunity to help improve Django by overseeing Windmill testing of the admin, and lots of other small testing improvements that will hopefully make it into trunk.
Testing AJAX Views in Django
- Apr 16 2009
A lot of the Django code we use at work has a special case for AJAX. It has been a kind of a pain to test, because the test client by default doesn’t use AJAX. Luckily the is_ajax call in the Django HttpRequest object is a simple check of an HTTP Environmental variable.
Adding Google Analytics to Sphinx Docs
- Apr 05 2009
This is just a reminder for myself later, or people looking on Google. Also note, that this method is useful for putting any Javascript content into your sphinx docs, but Analytics tracking is a common use case.
Really easy SSH tunneling
- Mar 21 2009
SSH Tunneling has become an invaluable tool that I probably use more than I should. I love tunneling, and use it all the time. This will be a quick tutorial on how to use the SOCKS proxy ability of SSH to allow you to tunnel your HTTP traffic through a remote server.
Twitter Spam
- Mar 15 2009
I keep hearing people talking about how twitter is going to be over run with spam now that it is becoming mainstream. I really don’t understand this viewpoint, and will take time here to outline what they could be talking about, and what can be done.
Pycon and Euro Djangocon
- Mar 08 2009
The ice is starting to thaw and I’m making my way out from under my first winter in Kansas. You know that spring is coming because the conference season is starting to bloom. I’m looking forward to a bunch of conferences that will be upcoming in the new few months. I’ll be attending two of them, and hope to see lots of interesting people there!
Automatically apply patches from Django’s (or any) Trac
- Feb 28 2009
Lately I’ve been delving into Django development a bit more, and applying people’s patches has been a bit of a hassle. You know you want to apply someones patch, but there are about five steps in between you and applying their patch to your source tree.
Incredibly useful SSH flag
- Feb 15 2009
So at work we have a lot of different django environments, scattered across varies servers. All of this information is kept in a central resource. We have the pythonpath, settings file, and the remote server that the client is on. So every time that I want to go do work on a different site, I have to ssh into that server, set the PYTHONPATH and DJANGO_SETTINGS_MODULE environmental variable, and then do what I want to do. This is not a huge deal, but it is annoying when you’re doing it 10-20 times a day.
Using rsync with django
- Jan 29 2009
Just a quick warning/tip on using Django with rsync, for other people pulling their hair out later.
Django Conventions Project Update
- Jan 26 2009
So about a month ago I started a project on my blog called the Django Conventions Project. It was an attempt to document and record conventions that are used across the community. Conventions are a great thing, with Python and Django relying on them a great deal. Things like private methods being underscored aren’t enforced on a language level, but are more of a gentleman’s agreement.
Encouraging Web Interaction for University Students
- Jan 22 2009
So today I would like to tell a story that really shows why the internet is an amazing thing. This month’s articles on A List Apart focused on web education for universities and I’d like to share a story about one way to empower students and show them the power of the internet. Teaching people to create for the internet is a great goal, but teaching people the power of the internet by example is something amazing as well. It is hard to motivate people to create things on the internet without the understanding of how that has value.
Review of Pro Django by Marty Alchin (1/2)
- Jan 21 2009
5 second review: Reading this book will make you a much better Django Programmer.
Django now has fast tests
- Jan 15 2009
As of Changeset 9756, Django’s test suite is A HELL OF A LOT FASTER. This was one of the 1.1 Features and probably the one I was looking forward to the most. Django Unit Tests now run inside of a transaction.