[Answered ]-Django Test key association

1👍

ValueError: Cannot assign "1": "QuestionMultipleChoice.lab" must be a "Lab" instance.

this means lab attribute trying to get Lab instance you can provide a lab instance to assign Lab instance you have to do like this

lab1 = Lab.objects.create(lab_name="testlab", pub_date=datetime.now(), lab_theory="test theory")

QuestionMultipleChoice.objects.create(question='This is a test question', lab=lab1)

Leave a comment