@task<EOL>def create_notifications(users, notification_model, notification_type, related_object):
<EOL>Notification = notification_model<EOL>additional = related_object.__dict__ if related_object else '<STR_LIT>'<EOL>notification_text = TEXTS[notification_type] % additional<EOL>for user in users:<EOL><INDENT>n = Notification(<EOL>to_user=user,<EOL>type=notification_type,<EOL>text=notification_text<EOL>)<EOL>if related_object:<EOL><INDENT>n.related_object = related_object<EOL><DEDENT>n.save()<EOL><DEDENT>
create notifications in a background job to avoid slowing down users