Я получаю ошибку:
Значение исключения: (1110, «столбец» около «задан дважды»)
Когда я просматривал страницу с ошибкой Django, я заметил, что настройки модели User, похоже, добавляются в Список дважды.
Это, кажется, происходит здесь в django / db / model / base.py в base_save ():
values = [(f, f.get_db_prep_save(raw and getattr(self, f.attname) or f.pre_save(self, True))) for f in meta.local_fields]
это то, что страница ошибки Django показывает значения:
values = [(<django.db.models.fields.CharField object at 0xa78996c>, u'kallie'),
(<django.db.models.fields.CharField object at 0xa7899cc>, ''),
(<django.db.models.fields.CharField object at 0xa789a2c>, ''),
(<django.db.models.fields.EmailField object at 0xa789a8c>, u'kallie@email.com'),
(<django.db.models.fields.CharField object at 0xa789b2c>, 'sha1$d4a80$0e5xxxxxxxxxxxxxxxxxxxxddadfb07'),
(<django.db.models.fields.BooleanField object at 0xa789bcc>, False),
(<django.db.models.fields.BooleanField object at 0xa789c6c>, True),
(<django.db.models.fields.BooleanField object at 0xa789d2c>, False),
(<django.db.models.fields.DateTimeField object at 0xa789dcc>, u'2010-02-03 14:54:35'),
(<django.db.models.fields.DateTimeField object at 0xa789e2c>, u'2010-02-03 14:54:35'),
# this is where the values from the User model customizations show up
(<django.db.models.fields.BooleanField object at 0xa8c69ac>, False),
(<django.db.models.fields.CharField object at 0xa8c688c>, None),
(<django.db.models.fields.PositiveIntegerField object at 0xa8c69cc>, 1),
(<django.db.models.fields.CharField object at 0xa8c69ec>, 'b5ab1603b2308xxxxxxxxxxx75bca1'),
(<django.db.models.fields.SmallIntegerField object at 0xa8c6dac>, 0),
(<django.db.models.fields.SmallIntegerField object at 0xa8c6e4c>, 0),
(<django.db.models.fields.SmallIntegerField object at 0xa8c6e8c>, 0),
(<django.db.models.fields.SmallIntegerField object at 0xa8c6ecc>, 10),
(<django.db.models.fields.DateTimeField object at 0xa8c6eec>, u'2010-02-03 14:54:35'),
(<django.db.models.fields.CharField object at 0xa8c6f2c>, ''),
(<django.db.models.fields.URLField object at 0xa8c6f6c>, ''),
(<django.db.models.fields.CharField object at 0xa8c6fac>, ''),
(<django.db.models.fields.DateField object at 0xa8c6fec>, None),
(<django.db.models.fields.TextField object at 0xa8cb04c>, ''),
# at this point User model customizations repeats itself
(<django.db.models.fields.BooleanField object at 0xa663b0c>, False),
(<django.db.models.fields.CharField object at 0xaa1e94c>, None),
(<django.db.models.fields.PositiveIntegerField object at 0xaa1e34c>, 1),
(<django.db.models.fields.CharField object at 0xaa1e40c>, 'b5ab1603b2308050ebd62f49ca75bca1'),
(<django.db.models.fields.SmallIntegerField object at 0xa8c6d8c>, 0),
(<django.db.models.fields.SmallIntegerField object at 0xaa2378c>, 0),
(<django.db.models.fields.SmallIntegerField object at 0xaa237ac>, 0),
(<django.db.models.fields.SmallIntegerField object at 0xaa237ec>, 10),
(<django.db.models.fields.DateTimeField object at 0xaa2380c>, u'2010-02-03 14:54:35'),
(<django.db.models.fields.CharField object at 0xaa2384c>, ''),
(<django.db.models.fields.URLField object at 0xaa2388c>, ''),
(<django.db.models.fields.CharField object at 0xaa238cc>, ''),
(<django.db.models.fields.DateField object at 0xaa2390c>, None),
(<django.db.models.fields.TextField object at 0xaa2394c>, '')]
Поскольку это приложение находится в производстве, я не могу понять, как использовать pdb.set_trace (), чтобы увидеть, что происходит внутри save_base.
Пользовательские настройки:
User.add_to_class('email_isvalid', models.BooleanField(default=False))
User.add_to_class('email_key', models.CharField(max_length=16, null=True))
User.add_to_class('reputation', models.PositiveIntegerField(default=1))
User.add_to_class('gravatar', models.CharField(max_length=32))
User.add_to_class('email_feeds', generic.GenericRelation(EmailFeed))
User.add_to_class('favorite_questions', models.ManyToManyField(Question, through=FavoriteQuestion, related_name='favorited_by'))
User.add_to_class('badges', models.ManyToManyField(Badge, through=Award, related_name='awarded_to'))
User.add_to_class('gold', models.SmallIntegerField(default=0))
User.add_to_class('silver', models.SmallIntegerField(default=0))
User.add_to_class('bronze', models.SmallIntegerField(default=0))
User.add_to_class('questions_per_page', models.SmallIntegerField(choices=QUESTIONS_PER_PAGE_CHOICES, default=10))
User.add_to_class('last_seen', models.DateTimeField(default=datetime.datetime.now))
User.add_to_class('real_name', models.CharField(max_length=100, blank=True))
User.add_to_class('website', models.URLField(max_length=200, blank=True))
User.add_to_class('location', models.CharField(max_length=100, blank=True))
User.add_to_class('date_of_birth', models.DateField(null=True, blank=True))
User.add_to_class('about', models.TextField(blank=True))
Django1.1.1 Python 2.5