Where is meta.local_fields set in django.db.models.base.py ?

Posted by BryanWheelock on Stack Overflow See other posts from Stack Overflow or by BryanWheelock
Published on 2010-02-02T23:07:38Z Indexed on 2010/04/20 14:03 UTC
Read the original article Hit count: 1486

Filed under:
|
|

I'm getting the error: Exception Value: (1110, "Column 'about' specified twice")

As I was reviewing the Django error page, I noticed that the customizations the model User, seem to be appended to the List twice.

This seems to be happening here in django/db/model/base.py in 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]

this is what Django error page shows values to be:

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'[email protected]'),   
(<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>, '')]  

Since this app is in Production, I can't figure out how to use pdb.set_trace() to see what's going on inside of save_base.

The customizations to User are:

    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

© Stack Overflow or respective owner

Related posts about python

Related posts about django