The Committee.save() is:
def save(self, *args, **kwargs):
if not self.slug:
self.slug = 'committee-%s' % self.id
And yes, after removing that save function everything works fine.
On Tuesday, October 20, 2015 at 9:32:20 PM UTC+3, Tim Graham wrote:
>
> What does the Committee.save() method look like? You have no problem if
> you remove that method?
>
> On Tuesday, October 20, 2015 at 2:22:24 PM UTC-4, Yaniv Mirel wrote:
>>
>> I've found out that this error is happening because I also have a def
>> save() function on the committee model.
>> So I am not sure if this is a bug or I am not suppose to have it like
>> that.
>>
>> On Tuesday, October 20, 2015 at 9:02:27 PM UTC+3, Yaniv Mirel wrote:
>>>
>>> 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/cb36759c-8d87-4a07-8700-bc0f30121ef0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.