You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class UserMoodLog(TimeStampedModel, Activity):
user = models.ForeignKey('users.User', on_delete=models.CASCADE)
is_happy = models.BooleanField(_("is happy"), default=False)
I want to create activity associated to this model on it's creation only when is_happy=True. I tried overriding create_activity() and call super create_activity() only when is_happy=True but a activity must be returned from that, otherwise this line
will throw error, as activity is None (because when is_happy=False I am not calling super create_activity() and thus None is returned by overridden create_activity())
Can someone please point me towards the right direction ?
The text was updated successfully, but these errors were encountered:
umair-tp
changed the title
Create activity based on instance attribute values
Create activity optionally based on instance attribute values
Nov 20, 2018
I have a model as following:
I want to create activity associated to this model on it's creation only when
is_happy=True
. I tried overridingcreate_activity()
and call supercreate_activity()
only whenis_happy=True
but a activity must be returned from that, otherwise this linestream-django/stream_django/managers.py
Line 64 in 9f5fcce
None
(because whenis_happy=False
I am not calling supercreate_activity()
and thusNone
is returned by overriddencreate_activity()
)Can someone please point me towards the right direction ?
The text was updated successfully, but these errors were encountered: