views:

96

answers:

1

In my models.py, I user these code to extent two fields:

User.add_to_class('bio', models.TextField(blank=True))
User.add_to_class('about', models.TextField(blank=True))

But when I creat a User :

user = User.objects.create_user(username=self.cleaned_data['username'], \
            email=self.cleaned_data['email'],password=self.cleaned_data['password1'])

There is an error like this :

ProgrammingError at /account/register/
(1110, "Column 'about' specified twice")

Request Method: POST 
Request URL: http://127.0.0.1:8000/account/register/ 
Exception Type: ProgrammingError 
Exception Value: (1110, "Column 'about' specified twice")

An I check the sql that django creats,I find it is very weird:

'INSERT INTO `auth_user` (`username`, `first_name`, `last_name`, `email`, `password`, `is_staff`, `is_active`, `is_superuser`, `last_login`, `date_joined`, `about`,'bio','about','bio') VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)'

There are two about and bio .But in Mysql table there is only one 'about' and 'bio'. On the another hand,in which case the models.py will be run twice, I`ve no idea.

I do not know why.Please help me!

+1  A: 

This is not a good way to store additional user information, for a number of reasons, as James Bennett points out in the linked thread. It's no surprise that you're getting weird SQL output and struggling to debug it. Keep things easy for yourself by using a related profile model instead.

ozan