0👍
✅
Remove to_field='nom'
from the nomTreballador
ForeignKey field and it will insert the Treballador
‘s primary key (an integer) instead of nom
(which is a string).
1👍
Your foreign key field is the problem.
Remove to_field and Django will automatically map it to ID
nomTreballador = models.ForeignKey(treballador)
- Best practise to remove stale documents in elasticsearch
- Django query created object in tests not working
- Django atomically limit check and increment counter for multiple tables
Source:stackexchange.com