On Wednesday, May 18, 2011 6:46:49 PM UTC+1, wilbur wrote: > > Hello, > > I continue to get errors when I try to view my model tables in Django > admin (1.3.0). The errors invariably refer to the name of a foreign > key defined in my models, with the '_id' appended to the name of the > field. My understanding was that by using a 'related_name' in the > column definition of the foreign key, it would override appending the > _id to the field name. > > The target table that the foreign key points to: > > class Sample(models.Model): ..........where id is the primary key > ..... > ..... > > class Specimen(models.Model): > spec_sample = models.ForeignKey(Sample,verbose_name='Sample > Name',related_name='spec_sample') > > and the error: > > column specimen.spec_sample_id does not exist > > How do I get Django to stop looking for spec_sample_id?? >
related_name has nothing to do with the db column - it controls the field the foreign key points to, in the target model. To set the db column, like with any other type of field, you use `db_column`. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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.