1👍
It doesn’t sound like you want to clone or copy these records – that’s something you should avoid in a normalized database anyway.
If you just want to update a single field, then you can do that with the update
queryset method:
MyModel.objects.filter(mailing_list=list_a).update(mailing_list=list_b)
If you’re talking about adding them to a different M2M relationship, then you can do that simply:
mailing_list_b.users.add(*MyModel.objects.filter(mailing_list=list_a))
- [Answered ]-Reverse for 'detail' with arguments '('',)' and keyword arguments '{}' not found
- [Answered ]-Display some field from two tables django orm
- [Answered ]-How does Django generates uuid?
- [Answered ]-Can I use a python metaclass to keep track of subclasses in separate files?
0👍
In Django 1.3 the solution is to iterate QuerySet and create copies like this:
from copy import deepcopy
old_obj = deepcopy(obj)
old_obj.id = None
old_obj.save()
Source:stackexchange.com