我已经更新了我的python版本和celery版本,现在无法从表单提交创建任务:
我的观点:
class SignupBase(FormView):
def get_form_class(self, **kwargs):
return SignupFormBase
def form_valid(self, form):
user = User(username=generate_random_username())
user.save()
signuptask = signup_user.delay(username=user.username,form=form)
提交时的追溯:
Traceback:
File “/home/USER/Env/DOMAIN/lib/python3.4/site-packages/django/core/handlers/exception.py” in inner
39. response = get_response(request)
File “/home/USER/Env/DOMAIN/lib/python3.4/site-packages/django/core/handlers/base.py” in _legacy_get_response
249. response = self._get_response(request)
File “/home/USER/Env/DOMAIN/lib/python3.4/site-packages/django/core/handlers/base.py” in _get_response
187. response = self.process_exception_by_middleware(e, request)
File “/home/USER/Env/DOMAIN/lib/python3.4/site-packages/django/core/handlers/base.py” in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File “/home/USER/Env/DOMAIN/lib/python3.4/site-packages/django/views/generic/base.py” in view
68. return self.dispatch(request, *args, **kwargs)
File “/home/USER/Env/DOMAIN/lib/python3.4/site-packages/django/views/decorators/cache.py” in _wrapped_view_func
57. response = view_func(request, *args, **kwargs)
File “./apps/signup/views.py” in dispatch
203. return super(SignupBase, self).dispatch(request, *args, **kwargs)
File “/home/USER/Env/DOMAIN/lib/python3.4/site-packages/django/views/generic/base.py” in dispatch
88. return handler(request, *args, **kwargs)
File “/home/USER/Env/DOMAIN/lib/python3.4/site-packages/django/views/generic/edit.py” in post
183. return self.form_valid(form)
File “./apps/signup/views.py” in form_valid
448. signuptask = signup_user_locally.delay(username=user.username, form=form)
File “/home/USER/Env/DOMAIN/lib/python3.4/site-packages/celery/app/task.py” in delay
413. return self.apply_async(args, kwargs)
File “/home/USER/Env/DOMAIN/lib/python3.4/site-packages/celery/app/task.py” in apply_async
536. **options
File “/home/USER/Env/DOMAIN/lib/python3.4/site-packages/celery/app/base.py” in send_task
709. root_id, parent_id, shadow, chain,
File “/home/USER/Env/DOMAIN/lib/python3.4/site-packages/celery/app/amqp.py” in as_task_v2
335. kwargsrepr = saferepr(kwargs, self.kwargsrepr_maxsize)
File “/home/USER/Env/DOMAIN/lib/python3.4/site-packages/celery/utils/saferepr.py” in saferepr
74. o, maxlen=maxlen, maxlevels=maxlevels, seen=seen
File “/home/USER/Env/DOMAIN/lib/python3.4/site-packages/celery/utils/saferepr.py” in _saferepr
104. for token, it in reprstream(stack, seen=seen, maxlevels=maxlevels):
File “/home/USER/Env/DOMAIN/lib/python3.4/site-packages/celery/utils/saferepr.py” in reprstream
155. for val in it:
File “/home/USER/Env/DOMAIN/lib/python3.4/site-packages/celery/utils/saferepr.py” in _chainlist
91. size = len(it)
Exception Type: TypeError at /signup/ Exception Value: object of type ‘SignupFormBase’ has no len() Request information: USER: AnonymousUser
GET: No GET data
POST: last_name = ‘Testing’ mobilephone = ‘99999999’ csrfmiddlewaretoken = ‘ShNfv74MEpYdvtbsGcC5lxGIsuuHVz73DNrHqDjsjKtFoDNW4po50cdLF2OXfrJr’ email = ‘testing@test.com’ first_name = ‘Test’
我错过了一些新的芹菜吗?用芹菜打败的其他任务工作正常,只有这一项任务不是。
答案 0 :(得分:0)
试试这个
class SignupFormBaseWithLen(SignupFormBase):
def __len__(self):
return 10 #here you have to set which len you should pass
此方法用于检查要传递给芹菜任务的参数的大小
然后
class SignupBase(FormView):
def get_form_class(self, **kwargs):
return SignupFormBaseWithLen