Extending django-registration using signals

前端 未结 1 909
无人共我
无人共我 2020-12-13 16:50

I have found here on stackoverflow a solution to extend django-registration with new fields using signals. Here\'s the link : http://dmitko.ru/?p=546 .
I have created ex

相关标签:
1条回答
  • 2020-12-13 16:53

    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.

    0 讨论(0)
提交回复
热议问题