DJango Signals with Custom Arguments

I am trying to learn how to work with Django signal and maybe what I want to make work is impossible. I have two models User and Client. I want to create a Client and then use that Client ID to create a User. How do I pass user details to my signal?

signals.py

def client_created_handler(*args, **kwargs):
    print(args, kwargs)

views.py

client_query = Client.objects.create(client_name=request.POST.get('client_name'), address=request.POST.get('address'), email=request.POST.get('client_email'), phone='12345', website=request.POST.get('web'), created_by=request.user)

custom_signal_kwargs = {
    "email": request.POST.get('contact_email'),
    "first_name": request.POST.get('first_name'),
    "last_name": request.POST.get('last_name'),
    "client": client_query,
    "user_role": 'Super User'}

post_save.connect(client_created_handler,Client,**custom_signal_kwargs)

The error I am getting is : TypeError: ModelSignal.connect() got an unexpected keyword argument 'email'. What am I doing wrong?

Back to Top