14👍
✅
You query Programme
and assign to programme
, but you never use the result anywhere. Just remove that line.
32👍
I think you are looking for select_related()
.
This line:
actors = Actor.objects.filter(programme = programme_id)
should look like this:
actors = Actor.objects.select_related().filter(programme = programme_id)
Unfortunately as emphasized here: Get foreign key objects in a single query you will only be able to retrieve actors that way as select_related
only works on objects having ForeignKeys and not vice versa.
- [Django]-Django: How can I create a multiple select form?
- [Django]-Why won't my GenericForeignKey cascade when deleting?
- [Django]-How do I install psycopg2 for Python 3.x?
Source:stackexchange.com