Note that there are some explanatory texts on larger screens.

plurals
  1. POPass additional parameters to post_save signal
    primarykey
    data
    text
    <p>hey i have a user registration form in my django application which collects additional data while a user is trying to register such as address, city, country, phone number etc.</p> <p>This data is saved in the Account model class through <code>post_save</code> signal. The user creation process goes something like this :</p> <pre><code># Function to Create user Account/Profile def create_user_account(sender, instance, created, **kwargs): if created: models.Account.objects.create(user=instance) # Create User / User Registration def UserRegistration(request): if request.method == 'POST': username = request.POST['fn'].capitalize() + ' ' + request.POST['ln'].capitalize() # CREATE USER newuser = User.objects.create_user(username=username, email=request.POST['email'], password=request.POST['pw']) newuser.first_name = request.POST['fn'].capitalize() newuser.last_name = request.POST['ln'].capitalize() newuser.save() return HttpResponse(username) #Post Save handler to create user Account/Profile post_save.connect(create_user_account, sender=User) </code></pre> <p>Here the <code>UserRegistration</code> function is called when a user posts a form and under this function i can get the POST data, what i want is to pass that data to create_user_account method so that it fills in the fields in the Account model.</p> <p>Right Now i do see Account Objects created in the database but all the fields except the user field are empty. Obviously, because the POST variables are not being passed to the <code>create_user_account</code> method.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload