[Answered ]-Django filter form field objects by existing one-to-one relation

1👍

Now I would like to exclude all already assigned cards from the form dropdown.

I’m assuming from this you want a queryset of all cards that aren’t on the far side of a pcslot.card relationship. If so, then you can just use a relational field in your filter. So

cards_without_assigned_slots = card.objects.filter(pcslot__isnull=True)

Note, it’s more pythonic to name your classes with CamelCase (so Card instead of card)

Leave a comment