I need help with Python code
copy_groups = Group()
groups = Group.query.filter(Group.project_id == curent_project_id)
for i in groups:
copy_groups.project_id = curent_project.id
copy_groups.name = i.name
db.session.add(copy_groups)
db.session.commit()
When I used this code it was added only last group
, but I need add all group
in groups
.
When I used
copy_groups = Group()
groups = Group.query.filter(Group.project_id == curent_project_id)
for i in groups:
copy_groups.project_id = curent_project.id
copy_groups.name = i.name
db.session.add(copy_groups)
db.session.commit()
I had error.
But I need add all group
in groups
Please help me with this problem. Thank you.
copy_groups = Group()
insidefor
loop – furas 45 mins ago