我正在尝试使用 RQ 创建后台作业:
import django_rq
def _send_password_reset_email_async(email):
print(email)
# Django admin action to send reset password emails
def send_password_reset_email(modeladmin, request, queryset):
for user in queryset:
django_rq.enqueue(_send_password_reset_email_async, user.email)
send_password_reset_email.short_description = 'Send password reset email'
我一直收到这个错误,似乎我在做一些愚蠢的事情?
Traceback (most recent call last):
File "/home/lee/Code/cas/venv/lib/python3.4/site-packages/rq/worker.py", line 568, in perform_job
rv = job.perform()
File "/home/lee/Code/cas/venv/lib/python3.4/site-packages/rq/job.py", line
495, in perform
self._result = self.func(*self.args, **self.kwargs)
File "/home/lee/Code/cas/venv/lib/python3.4/site-packages/rq/job.py", line 206, in func
return import_attribute(self.func_name)
File "/home/lee/Code/cas/venv/lib/python3.4/site-packages/rq/utils.py", line 151, in import_attribute
return getattr(module, attribute)
AttributeError: 'module' object has no attribute '_send_password_reset_email_async
'