Coder’s Eye

A site about one of the three passions in my life.

Coder’s Eye header image 2

First use of the Django Magic Removal

February 24th, 2006 · 3 Comments

Django Last night I took a break from my most recent Django app, a mailing-list manager, to explore the new "Magic Removal Branch".

I diligently followed the instructions on the Django Wiki to change my existing code. There were more changes needed than I’d anticipated, but they all made sense, so I didn’t mind. Better, I agreed philosophically with all of them.

Basically, the idea is to make Django apps act more like normal Python modules. That means ceasing all the “magic”, where it used to automatically provide entire new classes to manage objects, and used to magically move around the modules, making them available in namespaces you hadn’t explicitly named. I found that confusing, to be honest. I always had to look at example code to find out where the magic stuff was going to be. The magic, which was supposed to be helpful, actually ended up costing me time and thought.

Roadblock 1 - Database Init

Unfortunately, I’m not all the way there yet in migrating my code. First, I ran into a significant problem with database initialization. That is, it didn’t work.

$ bin/admin.py init

File "/sw/lib/python2.4/site-packages/django/core/management.py", line 498, in init
contenttypes_app = models.get_app('contenttypes')

File "/sw/lib/python2.4/site-packages/django/db/models/loading.py", line 30, in get_app
raise ImproperlyConfigured, "App with label %s could not be found" % app_label

ImproperlyConfigured: App with label contenttypes could not be found

OK, I restored the old database. It was a good thing I backed up before trying this! I then executed the SQL recommended on the Wiki to convert an existing install to the new branch. That mostly worked, but complained that a few tables were missing. “django_flatpages”? Never used that one, I assume it was a contrib module.

Roadblock 2 - code changes

I think I’ve converted all the existing code correctly, but the server dies on start. Apparently, I did not convert my old "”Class META" to the new "Class Admin" correctly. I’m sure I’ll knock that problem down the next time I have a moment to tackle the conversion. Unfortunately, I ran out of time, exhausting the one hour I had left before “The Daily Show” last night.

Conclusions

Absolutely worth the pain. It will work with a little more tweaking. These are normal pains to experience when using a pre-release, actively developed branch.

Update: The contenttypes error is corrected by a patch available from bug #1280.

Technorati Tags: , ,

Tags: Django · Python

Bookmark this article

del.icio.us:First use of the Django Magic Removal digg:First use of the Django Magic Removal spurl:First use of the Django Magic Removal wists:First use of the Django Magic Removal simpy:First use of the Django Magic Removal newsvine:First use of the Django Magic Removal blinklist:First use of the Django Magic Removal furl:First use of the Django Magic Removal reddit:First use of the Django Magic Removal fark:First use of the Django Magic Removal blogmarks:First use of the Django Magic Removal Y!:First use of the Django Magic Removal smarking:First use of the Django Magic Removal magnolia:First use of the Django Magic Removal segnalo:First use of the Django Magic Removal gifttagging:First use of the Django Magic Removal

3 responses so far ↓

Leave a Comment