1👍
What you can try doing is:
delivery = Delivery.objects.get(name="some_name")
(Just a small side note: remember that Delivery model must have a single object associated with “some_name”, otherwise get() will throw an error that 2 objects have been returned)
Now,
permissions = delivery.permissions.all()
con = Content.objects.get(name="content_name")
(same side note applies)
Now simply do: con.recipients.add(*permissions)
. And if you want to add same permissions to all the Content objects, then you can simply loop through every object of Content.objects.all()
and do the above add
operation done above for a single content object.
Hope this helps.
0👍
You might want to try iterating over the delivery permissions and adding a content recipient for every permission in the loop.
for perm in self.permissions.all():
content.recipients.add(perm)
content.save()
- Creating/ guessing the underlying models from JSON response
- Validation on CreateView and UpdateView in django always being triggered, even when model doesn't/shouldn't
- Django login user, after successful login user stay on same page
Source:stackexchange.com