[Answered ]-Django: ValueError exception when assigning one-to-many member variable

2👍

Use get() instead of filter():

the_team = Team.objects.get(name='Django_FC')

Quote from docs:

filter() will always give you a QuerySet, even if only a single object
matches the query – in this case, it will be a QuerySet containing a
single element.

If you know there is only one object that matches your query, you can
use the get() method on a Manager which returns the object directly.

👤alecxe

Leave a comment