[Answered ]-Django ForeignKey Required?

1👍

It sounds like your actual database is out of sync with your model. You’ll want to either drop and recreate your database using manage.py syncdb (easiest, but you will lose the data unless you use something like fixtures to reload initial data) or use a migration tool like South to upgrade your existing database to reflect the new data model.

1👍

You can try this on the manage.py shell:

from bar import models
l=models.Location("here")
s=models.Student(name="fred",email="foo@bar.com")
e = models.Exam(place=l,taker=s,score=99.9)

which I can do with no errors… Looks good to me..

0👍

In the admin.py file I had inlines = [StudentsInline] setting. This tries to enforce adding multiple Students to one exam (thinking it’s on the One side of a OneToMany relationship).

👤Josh K

Leave a comment