You are not logged in.

Change Language:

Freelancer? Consultant? Check out: WorkTrail - Time Tracking made easy
Board » Django » Models » Updating models to include foreignkey relation

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





Powered by Sphene Community Tools