As announced at the end of last month, we took it upon ourselves to create a weblog application. The main point was to replace Typo and reduce the large overhead the weblog was creating on the server. We wanted a fully functional weblog, but didn't need all the bells and whistles from Typo. It's pretty much finished now, and it was a lot of fun to work on.
Here are some of the features:
I'm considering releasing it as another open source project. Let me know if you're interested in using it or helping out with the project.
1 Comment Tags: Blog, Django, Open Source
There's a nice extension to the Python implementation of Markdown that allows for syntax highlighting of code. It's called CodeHilite, and it allows you to use a couple of different syntax highlighting tools, one of which being Pygments. Pygments and CodeHilite are great except that Objective-C syntax highlighting hasn't been implemented in Pygments.
Fortunately the Pygments team has made it pretty easy to create a new Lexer. I quickly modified the CLexer to create an ObjectiveCLexer. It's not really ideal, but it works. If you have improvements to this Lexer, please email me and/or comment on the ticket I created for the Pygments team.
No Comments Tags: Blog, Code, Pygments, Python
Django's Model class is intended to be subclassed when creating a model for your application. That's about the only intended use. But what if you want to add some extra functionality to Django's model class that all of your models can use?
You would think that something like this:
from django.db import models class M(models.Model): def something_special(self): pass class MyModel(M): field = models.CharField(maxlength=255)
would work just fine, but it doesn't work as desired. There's a good reason why it doesn't. Here's the MySQL code that Django produces for this setup:
BEGIN; CREATE TABLE `myapp_mymodel` ( `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `field` varchar(255) NOT NULL ); CREATE TABLE `myapp_m` ( `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY ); COMMIT;
which helps explain why it doesn't work as desired. Django considers the M class a valid model, one that can be saved to the database, so it creates an entry in the database for it. We don't need or want it in the database, though. We just want to extend the basic model class.
Read More...7 Comments Tags: Code, Django