您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

services.py 482B

123456789101112131415161718192021
  1. from django.db.models import get_model
  2. Notification = get_model('customer', 'Notification')
  3. def notify_user(user, msg, category=None):
  4. """
  5. Send a simple notification to a user
  6. """
  7. Notification.objects.create(
  8. recipient=user,
  9. subject=msg,
  10. category=category)
  11. def notify_users(users, msg, category=None):
  12. """
  13. Send a simple notification to an iterable of users
  14. """
  15. for user in users:
  16. notify_user(user, msg, category)