ForeignKey automatic attribute does not depend on db_column
|Reported by:||anonymous||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||1.3|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Here is an example:
class Author(models.Model): name = models.CharField(max_length=10) class Book(models.Model): name = models.CharField(max_length=10) author = models.ForeignKey(Author, db_column="author_key")
As from django documentation it will create a column in the database by appending '_id' to the field name, in our case it will be 'author_id'. It will also create an attribute author_id for the Book's instance. The database column name can be overwritten by defining db_column, this is what I did in my example. However, I expect that attribute will be changed from author_id to author_key but it does not happen.