In Uncategorized

I recently wrote an article on extending the user model for email login instead of username. I will use the same code only now allow my customers (aka users) to login. In order to do this, i will need to create a “User” for  each customer model created. Here what my NEW customer model looks like.

Source Code: Link

Right now as our project stands we can now add a user to each customer. But this is not enough, we need our user to be generated and attached to the customer automatically when a customer is created. To complete this we will use the django Post_save signal.

Our signal will fire when a customer is generated. It will create a user and became the parent to that customers user field.

First we will import post_save and pre_save

No we will write a signal that sets a default password to all customers and uses there email to set the users info.

Test this by going into the adin panel and create a customer with a email and name only. Now anytime we create a customer a user will be generated.

Contact Us

We're not around right now. But you can send us an email and we'll get back to you, asap.