[Answer]-Django: set number of ForeignKey relations by integer value in another model

1πŸ‘

βœ…

I’m not really clear on how you assign messages to tasks. However, if you need the ability to have multiple elements on each side of a relationship, you should use a ManyToManyField, not a ForeignKey.

Depending on what you are actually doing, you should be able to validate the correct number of messages according to num_of_tweets – for example, if you’re assigning messages via a form, you can do the validation there.

Leave a comment