Saturday, June 20, 2009

ModelAdmin readonly fields

Finalizing my web application, there was a few outstanding patches left to do. One of this I always felt strange why it was left out in the open. Django's admin interface form by default allows you to edit the primary key of the model. I always felt strange why it allowed this as it led to unexpected behavior. My users would edit the primary key expecting the changes to be done on the record which of course did not happen as django created another new object with the new edited id.

In solving this bug I was hoping that django's admin model allowed for something like 'readonly = ( 'id_field')' or something like to that respect. Just thinking out aloud but shouldn't this be automatically done for all primary key fields in ? Shouldn't the primary key be made non editable by default unless explicitly stated in the definition? Even then should the primary key be allowed to be edited? If a user were to be allowed to edit the primary key, would it really be editing or 'cloning' a new object with similar data but differing ids? I haven't really done a thorough search yet but I think by default all the fields is open to edit in the current django's ModelAdmin. Of course you hide the field away by chucking the field in the exclude tuple in your model's admin declaration but what if the user wanted to see that field? I was actually quite surprised when a declaration of fields that should be readonly in my ModelsAdmin did nothing. That was the first way I thought of doing it anyway.

The best would be a new tuple called readonly that would declare fields that are readonly in the change_form. To cut a long story short, I found someone had already created a snippet for it here. Works perfectly and it's exactly what I was looking for. The questions that remain however are:

1. Why isn't this in the core?
2. Should you actually allow primary key fields to be edited ?!

Tuesday, June 16, 2009

Ownership and responsibility

One thing that most smaller companies or any company for that matter really treasures are employees who take ownership of what they do. This is because employees that take ownership often will go the extra mile for a project because they feel that they own the project. In my opinion this is hard to create in a employer-employee based company because of the inherent weakness of this structure. Employees are normally paid monthly. Whether they take on more or less projects, their salary will still come in, so the less they do the better off they are. Taking on the responsibility of a project will only give them more headache and more to answer to.

The boss who wants to create this kind of situation must be brave enough to take the leap into somewhat unchartered region. Profit share. You want partners start treating your employees like partners and I am sure they will rise up to the challenge. Trust them and allow them to make mistakes. Mistakes are the single most important asset for a small rising star. They are your mistakes and they are there to show you the way. Learn from them and cease making them mistakes. Mistakes are good. Expect to make many of them. The more you make the higher the chances of success. You know in the beginning your staff will screw up, except their work anyway making as least modifications as possible. Asking your staff to make a 10 page writeup only to at last use the last 2 sentences will be a killer on morale and will create the "I-don't-give-a-shit" employees. Let them make mistakes and take a chance with them. They will appreciate it.

Follow through on your words. Expecting people to own a project without any compensation or carrot will just create a situation where your people will feel exploited and words will sound hollow. Who in their right minds want to take on extra work for nothing? Bosses or companies owners who realize this early will be able to tap into the entrepreneur side of their employees and create a situation where their employees will naturally take on extra responsibilities without fuss. As the owner or the boss you main job is to step out of the way of your people as they do their work offering your support along the way. At the end of the day if your people feel that they have achieved something with the least help from you as possible then you are successful in creating people who take on ownership of projects and you in the would have gained leverage.

Thursday, June 11, 2009

Google Docs Office killer Not?!

Those who know me a bit might know that I sell Google Apps as one of the many interest in business. Lately however I find that I cannot seriously sell Google Docs and expect them to use google docs to replace Microsoft Office. Google docs might just be good for doing simple documents and nothing more than that.

I say that for a few reasons:

1. Documents cannot exceed 50k. Now if an organization were to depend on Google docs entirely how is it able to do some serious document work if it has this limitation?

2. For simple formatting google docs is superb. In fact I like it so much I tried living of it exclusively for a little while until I found that for real work like doing quotes and invoicing you had to know html to edit the templates. Now how can you expect a company's secretary or the admin staff to know how to edit html?! Fail! Complete utter fail!

3. There is no way to password protect a document easily. Now I do not need comments telling with a webpage detailing the hows of doing this across a few pages of hacking. The point here is that it cannot be done by customers so it's a fail.

Until these issues are solved or at least worked around, google don't even expect to be able to dislodge Microsoft Office. Infact, looking at the technical challenges that you have to surmount, I am beginning to think that it might not even be worth the fight.

As for now I will continue to sell my services configuring Google Apps but I will concentrate more on pushing the email and the Calendaring.

Wednesday, June 10, 2009

Django CRM?

Few of our customer came up asking for some crm functionality from us. Quite a few actually. These are not full blown sugarcrm kind of requirements. Actually they are very simple functionality. Looking at these requirements, it made me think that going for something like sugar would be like taking three steps back to gain a step forward. I would have to spend my time editting out functionality and it would be a dumbing down process all over again. Rather than go this route I thought it would be nice to probably use Django to build them this.

Looking around here are some of the links I found relating Django to CRMs:

Seems that most of them are either abandoned or not very usable. Sigh ...

That's about all that I found for django crm. The rest of the solutions are too much of an overkill in terms of hacking time or completeness. Okay now my favorite part ... back to the Django drawing board.

Tuesday, June 2, 2009

Django talk

Just finished my Django talk yesterday and I must say while a few dude and dudettes walked out, there was generally quite good interest (better than I thought) from a few young people in the crowd. Initial talks are also underway to form a PUG or Python User Group locally here in Malaysia. I would really like to see this happen. The response has been quite good infact I would go so far as to push to even include Python in some programming curriculum in our universities.

That is the only way I would see Python growing and getting more acceptance. On that note too I also mentioned during my talk for frameworks like ROR, Django, TG and it's like to gain more acceptance in the industry, more articles or howtos concentrating on enterprise level deployments of these frameworks have go to be available.

Something like:

I would really like to see Django grow from it's current girth to something that could rival all the J2EE stuff out there.

Nice link here to some good django slides ... damn could have used those for my talk :).

P/S -Thanks to all those readers who came to the talk :)