Django model object instantiation with many to many field. | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 2

Django model object instantiation with many to many field.

Hi, This is my models.py: class notification(models.Model): toUser = models.ManyToManyField(User) How do I add all users to a new notification? I can reference one user: user = User.objects.get(username='abc') notification = Notification.objects.create() notification.users.add(user) How do I add all users without a for loop finding each user and adding again and again?

2nd Jun 2020, 3:31 PM
Arnesh
Arnesh - avatar
1 Antwort
0
There are 100,000 people then? I want to message everyone.. It'd be too slow...
27th Jul 2020, 3:17 PM
Arnesh
Arnesh - avatar