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

> "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?"
>
> Isnt it the same thing? The only difference is, that django will add
> "_id" to it now and in the end result is the same, I still get the
> error.
>
> If my model looks like this:
>
> 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)
>
> It will get saved properly. If I add the foreign key, with or without
> db_column, I will get that naaasty error...
>
>
I'm confused. The model you showed in your original post had a field named
language_id and a ForeignKey field named label. The default column name for
the field named label would be label_id, so it would not conflict with a
field named language_id. The only reason it conflicted was because
db_column='language_id' had been specified on it.

It sounds like you are talking about a model that looks something like this:

class P(models.Model):
    language_id = models.IntegerField()
    language = models.ForeignKey(SomeOtherModel)

In that case, yes, you would get duplicate column names because the default
name for the ForeignKey column would be 'language_id', which is already in
use. The fix for that would be to specify another name for one of the
columns, by specifying db_column on one or the other of the fields, and
choosing a value for it that is not already in use for one of the other
fields in the model.

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