[Answer]-Django DatabaseError "more than one row returned by a subquery used as an expression" Editable related fields to object

1👍

Needed to pass only 1 object to the instance

owner = owners[0]

then

instance=owner

However, I am only able to add/edit pet names 1 owner at a time.
Thanks aamir for the help!

👤nlr25

0👍

I believe your error is in the second line of the views.py file. I believe it is the call to the get_object_or_404 method causing the error when you try to specify teacher.id in your template. The call to the get_object_or_404 method is returning more than one row from the database, so calling teacher.id is not possible on it from more than one row.

Leave a comment