1👍
✅
You try to add non-saved Subscriber to Tour.
You need to call sub.save()
before tour.subscribers.add(sub)
The tour
must also be saved before adding sub
.
The reason for this is the additional table that handles many to many relations (see docs). This table stores two Foreign keys – one for Tour
and one for Subscribers
. To save a row into this table both Tour and Subscriber should exist in database
👤Igor
Source:stackexchange.com