Hi,

I am getting this error when running model post save signal.
The error traceback is for gr.save()

it seems like the committee model is not saving before it need to be assigned 
to GroupRole model as a FK.

this is the post_save signal code.



@receiver(post_save, sender=Community)
def set_default_reasons(sender, instance, created, 
dispatch_uid='set_default_reasons', **kwargs):

if created:

committee = Committee(community=instance, name='Board', slug='main')

committee.save()


for group_role in settings.DEFAULT_GROUP_ROLES:

gr = GroupRole(committee=committee, role=instance.roles.get(title=group_role), 
group=instance.groups.get(title=group_role)) 

gr.save() 

 

 Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/edb760ef-e1db-470c-840b-e052f539d082%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to