On Sun, May 16, 2010 at 10:35 AM, Lukáš <lukash...@gmail.com> wrote:

>
> I would like to save a modified model, but I get Programming error -
> language_id field is specified twice.
>
> class ProductInfo(models.Model):
>    product_info_id = models.AutoField(primary_key=True)
>    language_id = models.IntegerField()
>    product_id = models.IntegerField()
>    description = models.TextField(blank=True)
>    status = models.IntegerField()
>    model = models.CharField(max_length=255, blank=True)
>    label = models.ForeignKey(Category_info, verbose_name =
> 'Category_info', db_column = 'language_id', to_field = 'node_id', null
> = True)
>
> I get this error because the foreign key uses as db_column
> language_id. If I will delete it, my object will be saved properly.
>
> I dont quite understand whats going on and since I have defined almost
> all of my models this way, I fear its totally wrong or maybe I just
> missunderstood it...
>
> Any ideas?
>

Since you have not specified db_column on the language_id field, the name of
the column for that field in the database table will be 'language_id'. But
then you also ask, by specifying 'language_id' as the db_column value for
the label field, for a 2nd column to have the exact same name. You can't
have two columns with the same name in a table, so you get an error.

Why are you specify db_column='language_id' for the label field? Why not
just let this field be given its default column name in the table?

Karen
-- 
http://tracey.org/kmt/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to