| Name | ovali |
|---|---|
| Email Address | n/a |
| Posts | 1 |
-
- 2012-05-22 13:10:21
- Updating models to include foreignkey relation
- Board » Django » Models
-
Hi,
Lets say I have two database tables, as follows:
1> Table Books
fields: ID, Title
2> Table Book_data
fields: book (same as ID above for the same book), author, publisher, pub_date
Now We have a django models file which represents both of these tables, without referencing the foreignkey relation ie where it should have been
book = models.ForeignKey(Books)
,it was just defined as book=models.IntegerField()
But if I want to now add this foreignkey relationship between Book_data.book and Books.id, how should I go about it? Is it possible at all to have this relationship automatically be applied to all the existing data in these tables? (Using Mysql db, in case you wanted to know)
Thanks in advance


