django: Change username max_length

June 28th, 2008

django maintains username and email separately. This is convenient but if you want to use the email as the username, the default authentication system has to be modified. Fortunately this is very simple in django. You need to write an ‘Authentication Backend’. The details of how to do this are very nicely covered here.

http://www.djangosnippets.org/snippets/74/

This introduces a slight problem. The max_length of email field is 75 characters, and that of username is 30. You can change this by editing the django source code (goto /django/contrib/auth and modify the User in models.py). But if you feel hesitant to change the source code for a single application (like me :)) then there is a simple solution. Place this line in your models.py (preferably at the top),


User._meta.get_field_by_name('username')[0].max_length=75

You need to make this change before you perform the syncdb command. After placing ths line, run the command,


python manage.py syncdb

the username field now has max_length=75.

django: Customizing django newforms output

June 9th, 2008

django newforms provide a quick and easy way to display and save data. You can chose to render form as list (as_ul), table (as_table) or paragraph (as_p). These methods also display the error messages appropriately against each field. This is really handy as it saves you a lot of development time.

I prefer to display form inside a table and therefore mostly use as_table. It renders form as table with two columns. The first column contains the label and the second one contains the input field. The default behavior of as_table is to display the error messages above the field. But what if you wanted to change this behavior but keep the powerful as_table function? Fortunately, the solution is a single liner (not surprisingly).

Define a class MyForm and override as_table method. Now use this class as the base class of every form instead of forms.Form class.

from django import newforms as forms

class MyForm(forms.Form):

      def as_table(self):
            return self._html_output(u'<tr valign="top"><th>%(label)s</th><td>%(field)s%(help_text)s<td>%(errors)s</td></td></tr>', u'<tr><td colspan="2">%s</td></tr>', '</td></tr>', u'<br />%s', True)

Now calling as_table method in template will display the error messages in front of the fields. Just make sure that the error messagas not that long or the size of your form will increase.

django: Add choices to form fields on runtime

May 26th, 2008

django forms are clean, powerful and quick way to edit objects. They provide initialization & rendering of all HTML fields. I found the ChoiceField (HTML select box) quite interesting. You can initialize it with choices attribute. These choices are a list of key, value pairs. Upon selection of value, the key is returned to server. This is very handy. But it would be even handier if we can set these choices on run-time. Fortunately, the elegant design of forms allows us to do just that.

example: suppose we have following models

class Region(models.Model):

     name = models.CharField(max_length=100)class Profile(models.Mode):

      user = models.ForeighField(User)

      region = models.ForeignField(Region,related_name='region_users')

class Item(models.Model):

      region = models.ForeighField(Region,related_name='region_items')

      name = models.CharField(max_length=100)

      code = models.CharField(max_length=20)

Using django new-forms, we can do this,

import newforms as formsclass MyForm(forms.Form):

      region = forms.CharField(max_length=100, required=False)

      items = forms.ChoiceField(choices=())

      quantity = forms.IntegerField(max_value=10, min_value=0)

def __init__(self, user, *args, **kwargs) :

            super(MyForm, self) .__init__(*args, **kwargs)

            self.fields['items'].choices = [(a.code, a.name) for a in Item.objects.filter(region=user.get_profile().region)]

It is important to call the __init__ of base calss before setting the choices. Calling the form.as_table will simply render the field with required choices. You can extend this example to involve any category-subcategory ChoicFields.

Perfect way to respond to a business plan

May 9th, 2008

Everyone always talks about how to write perfect business plan. You can find thousands of templates, suggestions, tips, tutorials, examples on writing business plan. But what about evaluating the plans?

Here is a simple template that both Angel investors and VCs can use to respond to funding requests.

We have carefully analyzed your plan and our understanding of your product is,<copy-paste 'Product Description' from Plan>

We realize your current investment status is,

<copy-paste ‘Status’ from Plan>

Your business model is reasonably sound which as you have mentioned is,

<copy-paste ‘Business Model’ from Plan>

However, you should come up with at least 2 more ways of monetizing your product to ensure you have covered all aspects.

We suggest following list of actions for you,

<copy-paste ‘How would you utilize the funding?’ from Plan>

You need more work before it can raise funding.
We suggest that you involve an experienced business person from your product domain.
We also suggest that you launch the product in beta phase and gather user feedback. 

Please send us the updated plan as soon as you proceed with these suggestions.
Thank You

I am sure that many investors already using this method.

To the first Apple Store in Pakistan

May 8th, 2008

“Apple Store in Pakistan!”

WoW! I have been waiting to get my hands on Apple products ever since…well…since I found out about Apple :). However, this was not the first time I heard this news. It has been rumored many times before but it always turned out be an unauthorized dealer.

 

But this time it seemed quite original. I had been seeing iRaffles ads for some days. And then the news finally came out. Raffles has partnered with Apple to launch first Apple products in Pakistan. Technically it is not an Apple store rather they are Apple Premium Resellers.

 

The electricity was out in the city so the pictures are not that great.

iraffles 1 iRaffles 2 iRaffles 3

Mac Pro,

mac pro 1 mac pro 2

A look at the specs,

mac pro specs

But the highlight of the store was definitely, Mac Book Air.

mac book air 1 mac book air 2 mac book air 3

We were able to have a nice chat with Ibrahim Qureshi, the Director of iRaffles. He told us how the existence of an authorized shop helps the customer. They will provide services, warranty and handle claims. So the customer can get his product fixed or replaced within three day rather than wait for weeks. They will also cover Apple products bought from any Apple authorized store from any country. He also mentioned that they are working to officially bring iPhone to Pakistan.

An important thing he mentioned is that Apple is a strictly ethical company. They absolutely DO NOT bypass the rules. If something is illegal, they will not do it. So it takes time for them to enter the market officially in different countries.

Lack of support has been a major issue for both individuals and corporates while considering Apple products. Even more important than the availability of a product is the quality of service you get after sale. Currently, Apple products can be bought from many sellers, but the service is not something to write home about. So by offering better service, you get more customers. And iRaffles do seem to realize this.

 

People have citicized them for not looking more New Yorkish and not having enough products but you always need a start to build on it. So despite the shortcomings, iRaffles looks promising. The important thing to see is how they enter the market. However, Apple products are not cheap. So I doubt we ll see every laptop replaced with mac book and every PC with Mac. But they certainly have the attention of advanced users.

iPhone Browser

May 2nd, 2008

If you like to have full access to data on your phone, a file browser is a must have. This is what I missed the most about iPhone. I could not manipulate my data on iPhone freely. Sure, I could SSH from laptop via network established over Wifi. But what the hell? I mean, why cant I just connect to iPhone over USB? It was quite frustrating till I found iphone browser that works over USB.

You can download & install iPhone browser from,

http://code.google.com/p/iphonebrowser/

Run iphone browser. You should see your phone contents like,

iphonebrowser

If you unlocked your phone through ZiPhone, iPhone browser will probably not list the complete file system. There is a simple solution for this.

  1. Open Installer app
  2. Add http://i.unlock.no to sources
  3. Install ZiPhone iBricker Fix (under Unlocking Tools)
  4. Now restart the iPhone browser. If it does not work, restart your iPhone and make sure it is detected by iTunes

Enjoy full access to your iPhone :)

Here are the sources that I used to get iphone browser working.

http://www.howardforums.com/showthread.php?t=1328988&page=1

http://code.google.com/p/iphonebrowser/wiki/Usage

MMS on iPhone

April 25th, 2008

iPhone cannot can send MMS. But you need some effort to do that :)

Following are the steps needed to configure your iPhone to send MMS.

What you need,

  • An iPhone (of course)
  • A connection with MMS enabled (of course)

How you do it,

  1. Jailbreak and unlock the iPhone *cough*
  2. Open the installer app
  3. Tap on ‘Sources’
  4. Add the source http://swirlyspace.com/SwirlySpace.xml to the list of sources
  5. Install Swirly MMS from the list of applications. It should be under the ‘SwirlySpace’ category
  6. Open SwirlyMMS, tap on settings
  7. Enter following settings
    • For Warid
      • MMSC - http://10.4.0.132/servlets/mms
      • Proxy - 10.4.2.1:8080
      • APN - mms.warid
      • username - leave blank
      • password - leave blank
    • For Telenor
      • MMSC - http://mmstelenor
      • Proxy - 172.18.19.11:8080
      • APN - mms
      • username - telenor
      • password - telenor
    • For Mobilink
      • MMSC - http://mms
      • Proxy - 172.25.20.12:8080
      • APN - mms.mobilinkworld.com
      • username - mobilink
      • password - mobilink
  1. Save settings
  2. You are now ready to send and receive MMS from your iPhone :)

Thanks to Yaser for providing me with settings from his i-mate K-JAM to send MMS on Warid connection.

Mehreen wants me to join b4bid

April 23rd, 2008

Question: How to build an auction site? A site to establish a connection between buyer and seller? How do you prevent bad deals? How do you get the right people to join?

Answer: Use a random girl’s picture, make sure the picture is attractive, use a good name and the users will just flock. Problem solved.

b4bid2.JPG

The case is simple, everyone wants to hook up with an attractive girl and hence will surely join the site. The assumption is correct, IF you are running a dating site. If I was interested in 19/f/khi or 17/f/lhr I would be on IRC, Facebook, orkut or better yet on a dating site. An auction site is the last place I would go looking for girls.

I believe there are better ways to promote an auction site. Here is Yaser’s take on auction.

Hacks@LUMS-101

April 8th, 2008

31 March 11:00 PM

The stars were dim, moon covered with light clouds, birds sleeping and people resting. At the same time, the geeks in Newt were up to something. The first ever hack in the history of LUMS CS was about to take place.

29 March 2:00 PM

The idea was under development for quite some time. We knew we had to do something on 1st April but what and how? Suggestions came from every corner of newt. Great minds invested countless hours on evaluating ideas such as,

> Cover the room’s entrance with wallpaper

> Fill the room with empty drink bottles

> Paint the room ceiling with multiple colors

> Move everything (including tables & computers) in Newt lab to some where else

and many others.

But the idea that took the prize came from Yaser. The mission was finalized as,

Mission

Subject: Dr. Umar Saif

Objective: Fill the room with balloons

This may not sound a great challenge but we had to do it with the door locked.
30 March 11:00PM
We analyzed Dr. Umar’s room and devised an ingenious plan. The plan was simple but elegant,

1> buy 200 balloons

2> get a couple of hand pumps

3> slide the balloons one by one below the door, fill them with gas

4> tie them with thread and push them in the room

After taking the oath of secrecy, the plan was finalized.
31 March 11:30 PM
We started the execution. But everything seemed to go wrong. I had already bought 100 balloons from a gift shop. But the balloons did not turn out to be strong enough. Next, the pumps Mansoor brought from his home were leaking. All seemed lost; but then Mansoor came up with a device to replace pumps (the patent for which has already been filed). It was yet a simple solution. Mount a balloon on a pepsi bottle, make a hole in the bottom and fill the balloon.

1 April 12:00 AM
The mission started. We mounted the balloons on the bottle, inserted the balloon in the room from under the door, filled it, tied it and released it.
The progress was slow. The danger of being caught was there :(. Balloons were popping and we hardly put 10 balloons in the room in first hour. On emergency notice, Mansoor and others went to buy more balloons from the nearby store.
1 April 1:00 AM
But with the inclusion of Murtaza we picked up the pace to an average of 1 balloon/minute. As the number of balloons increased in the room so did the adrenaline. Soon there were close to 100 balloons in the room. But we went on to put another 30-40 in there. When we stopped, it was 3:30 in the morning. Though tired, the sight of the room from the window was enough to keep us motivated.
Next day, the whole lab was waiting for Dr. Umar to come (which is usually not the case :)) but he did not. The balloons survived the whole day. We were unable to see Dr. Umar’s first reaction when he entered the room but the thought of opening a room full of balloons still puts a smile on our faces.

For more details refer, http://www.sharjeel.2scomplement.com

Startup Insiders 6 @ LUMS Lahore

February 24th, 2008

Frankly, I did not have high hopes for Startup Insiders #6 @ LUMS, after the disappointing experience at previous Startup Insiders #3 (as it was restricted to very basic things). But the gathering was exactly what it should have been. An informal, bi-directional, moderated and mature discussion.

Since I did not note down anything, I have to rely on my memory. So I will definitely miss things and might misquote. Also I will only be covering the best (IMO) points by each panelist. (See the video for details)


Jehan Ara and Jawad Farid introduced the panel and the format.

Panel

  • Jehan Ara
  • Jawad Farid
  • Dr. Umar Saif
  • Faisal Qureshi
  • Zia Imran
  • Fahad Bangish
  • Zafar Khan
  • Nadeem Malik

Format

Each panelist was given 2 minutes to answer the question (or face the consequences :)). The audience could interrupt the speaker at any time and direct the question to anyone/all panelists.

The Yellow Cards

But the best feature was, ‘The Yellow Cards’. Some people (including yours truely :)), were given yellow cards. If someone felt that the discussion was going off topic, he/she would raise the card and stop the conversation.

This minute change turned out to be the best thing. As with the previous event, a lot of people tried to jump in with whining and complaints. Though most of them were answered comprehensively by the panelist but we also made good use of the yellow cards. This moderation mechanism was one of those things that kept this discussion on track.

Discussion

It started off slowly, Jawad showed a series of advertisements including the ads for Apple’s 1984 Mac, Mastang, Lexus and FedEx. He explained the concept behind each individual ad and how it targetted a specific audience. The core thing out of that 30 minutes was,

You must be able to specify the attributes of your product in 30 seconds. Identify the qualities of your product and relate them to the customer needs such that it makes the customer ask for your card

After that it was primarily Q&A with the panelists with following highlights,


Jawad Farid

An entrepreneur does not complain but solves problems. This is critical as your customer does not care if its raining, your building is on fire or there are strikes. Buy generators to cover electricity shortage, dig holes and put tube wells to get water. Solve the problems you face, do not complain.

Know your customer, know his pain. Identify the points that are most painful and then convince him that your solution solves these pains better than any other exisitng solution. You can make the best product in latest technology but if you can not convince your customer to use it, its not worth anything to him.

These points convey the essence of entrepreneurship. Entrepreneurship is not about making money, its not about having a huge company. It is about solving problems, creating value and converting that value into money. Jawad was spot on with the details on how he got his first customer and how his company ended up having the business they are doing right now.


Jehan Ara

Jehan Ara was the anchor for most of the time and she sure did not make anyone sleepy. She added to almost every question but particularly to the questions pertaining to the ‘impossibilities’ of starting the business.

There are lot of problems with working in Pakistan.

  • resource dependency
  • lack of infrastructure
  • bad image of Pakistan

However, we must face these problems and try to solve them. Complaining will not help. Our universities need to produce good people, our people need to imporve our image by working hard and being honet. The image is not just built by government, but by the people. Companies in India face lack of infrastructure, poverty and bomb blasts at a much higher scale than Pakistan but still they manage to overcome these problems.

Frankly, I think the questions like ‘It is not possible to work in Pakistan’ should not be answered anymore. Entrepreneurship starts with annoying passion and belief in your idea. If you do not have faith in yourself, do all of us a favor and dont become an entrepreneur.

 

Dr. Umar Saif

Dr. Umar (looking fine and dandy as usual) spent a lot of time listening. But he added some valuable thoughts when it mattered.

One thing common in all these people is commitment and hard work. These people worked really hard at whatever they did, whether it were studies or business. Withouth hard work, you are bound to fail even in a job, let alone your own company.

Faisal Qureshi

Faisal Qureshi undoubtedly dominated the whole session with his all round personality. He was surrounded by no less than 15 people during the refreshment and at the ending. I am sure he could have easily won the NA elections today :).

 

 

I dont care WHY I dont use your product. The bottom line is that i DONT. I should be using it but I dont. Now figure out how can you make me use it. You only get 30 seconds before I leave your product and the image I have will stay with me.

Find your ‘Mamoon Akbar’

You have to find a link to your first customer. A customer probably gets 100 phone calls today for business and listens to 1% with some seriousness. But if his ‘Mamoon Akbar’ calls him and tells him about you, he will listen to you. Find that ‘Mamoon Akbar‘. This will open the door for you. After that its your job to ‘con’ him into buying from you (he later explained it as con from CONvince not from CONvict).

Before the customer buys your product, he decides if he wants to have a relation with you. Every thing matters in this regard. Dress up nicely, talk nicely and be honest. You have to look like in control. Do not let anyone else dress up and look better than you and take the center stage. If you cant do that, hire someone who can.

I guess I wont be showing up in the next gathering in slippers :P

MBA degree neither makes you a better human being nor a better business man, it only opens up doors for you that might not be opened otherwise.

*cough* *cough*

You are responsible for the two square feet you occupy. You destroy it when you trash the city, when you make a personal attack, when you lie or cheat. At the end of the day, be responsible.

You should aim to absorb and keep growing yourself, help others because that help will definitely come back to you.

Faisal’s thoughts about innovation, impact, responsibility and success were just extraordinary.

Some other good questions were,

Q: Three things you now have and wish you had when you started?

A:

Faisal Qureshi: People management

Nadeem Malik: If I had what I have now, I would not have been what I am now

Fahad: More money

After that, the discussion went off topic :(


Q: How to balance your team?

A: Find people who can complement your skills. If you cant implement a tech idea, find someone who can. If you cant sell, find someone who can sell.


Q: How to target a wide range of customers? (the long tail)

A: You should divide your customers in categories. Then build your strategy around each category. Each category has different buying power, needs and problems. Identify them and sell to them according to their needs.


Some lame questions/comments were,

-Give us some practical advice (meaning shortcut to success)

-We should not follow the examples of Yahoo! and Google (I ll be blogging about this later)

-How can we work in these awful conditions? (some more whining)

-You have to be experienced to start a company


Conclusion

I feel that 50% of the audience was the wrong type of audience. This event is for entrepreneurs, since not everyone can be an entrepreneur, not everyone should be in it. Currently, it is mainly advertised to the university students who treat it as a workshop for career making and even worse, a shortcut to making money.

The session started with me at a very low energy level, expecting not much. But as the session picked up the pace, it became more and more engaging. The penalists did not talk about WHAT they have accomplished, rather HOW they accomplished it. There were times when the discussion went off topic but was never derailed (we had lots of yellow cards to make sure). At the end of the session, I had a high energy level and motivation (despite getting only one sprite). I am sure the discussions with Jawad and Faisal Qureshi will provide me food for thought for a long time.