user-avatar
Today is Saturday
February 4, 2012

Tag: database

January 8, 2012

DjangoRedmineAdmin 1.0 released

by Thomas Capricelli — Categories: Admin, Django — Tags: , Leave a comment

I recently needed (again) to ‘browse’ a redmine database, and I used my DjangoRedmineAdmin application to do so. I took this opportunity to update the code and doing some more tests/fixes. As a result I decided to tag this as 1.0.

The main modifications are:

  • updated to comply with current redmine version (1.2.1 and 1.3.0)
  • updated to use Django 1.3 instead of Django 1.2, which is now deprecated.
  • added a lot of new improvements to the admin pages, such as displaying a list of related model instead of the raw id, or presenting data in a cleaner way.
  • it now works now with mysql too. Previous version would have problems handling boolean fields on a mysql database. We need to blame ruby ORB here, which actually handle boolean differently depending on the db backend. Sqlite3 was and is still supported.

You can clone the repository or download tarballs from the mercurial source page.

The wiki has more information / documentation.

September 27, 2008

Django browser for Redmine database

by Thomas Capricelli — Categories: Admin, Django — Tags: , 6 Comments

Do you know redmine ? This is, to my knowledge, the best project manager you could ever find out there. I like to describe it as ‘trac done well‘. It has only one, big, ugly, fat inconvenient for me : it is written on top of ruby on rails. I could tell you how slow it is (true), or how many security flaws are found everyday in the ruby/rails world. But the real reason I’m actually really concerned about ruby/rails is that I don’t know ruby. When I look at the code I don’t understand anything, and I can’t change something to ‘suit my needs’, as is so common in Free Software.

I wish it was written in Django.

Well, anyway, I spent some times today to create a small Django application in order to display stuff from the redmine database. For this, I’ve used the wonderful “inspectdb” feature of Django, which access a database and creates the (Django) models required to access it.

Then, I had to ‘adapt’ those models and to create an admin.py file so that I could browse (and even modify) the database from django.

Adapting meant:

  • removing all the “id” field, they are automatically created by Django and it seems rails use the very same name (“id”) so this is compatible.
  • Change the “obvious” references to other model from IntegerField to ForeignKey
  • Some models reference themselves, you need to use a ForeignKey to ‘self’ (including quotes) to do that.
  • add some __unicode__(self) for the most important/obvious models

The admin works was basically about:

  • Creates Admin objects for all models (thanks vim’s macro!)
  • add list_display / list_filter args for the most important ones

And the remaining problem is :

  • It seems Boolean from ruby/rails have the values ‘t’/'f’ while those from django have 1/0 (fixed since then)

Mandatory screenshot (corresponding to the public stuff from http://labs.freehackers.org):

Example of djangoredmineadmin in use

Link to the project homepage

© 2012 Thomas Capricelli All rights reserved - Wallow theme v0.46.5 by ([][]) TwoBeers - Powered by WordPress - Have fun!