Extending django-registration using signals

喜夏-厌秋 提交于 2019-11-28 18:28:52

May be the problem is in the way how you connect to the signal? In my solution in was:

def user_created(sender, user, request, **kwargs):
    form = UserRegistrationForm(request.POST)
    data = profile.Profile(user=user)
    data.city_id = form.data["city"]
    data.save()

from registration.signals import user_registered
user_registered.connect(user_created)

and in yours:

from django.dispatch import Signal
# A new user has registered.
user_registered = Signal(providing_args=["user", "request"])

Also, I would switch on logging to ensure that your method is called. My solution works fine in the production, if you need I can look for other details.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!