I have two Registration pages: Register as Buyer, Register as Seller.
on both Pages , I've included Normal Registration and social authentication using Google and Facebook.
I've added social authentication using Django all-auth, but cannot get user_role.
[1][Registration Page]:
[2][Signup with Google]: After signup : User is registered as Blank Login.
MY TASK : Is to assign user_type on both the buttons: Buyer and Seller. on click button redirect user to its particular Registration Page and Login/Signup with Social Authentication and after Successful-Login Redirect User to its Page and show user_type in Django-administration-panel as:
Buyer | test@gmail.com | True
Seller | demo@gmail.com | False
#models.py
class Profile(models.Model):
user_type = models.CharField()
user = models.ForeignKey(User, related_name="profile")
this will run after the user has created.
#signals.py
from django.db.models.signals import post_save
from django.dispatch import receiver
from . models import Profile
from django.conf import settings
User = settings.AUTH_USER_MODEL
@receiver(post_save, sender=User)
def create_profile(sender, instance, created, **kwargs):
if created:
Profile.objects.create(user=instance, user_type=instance.user_type)
edit: I don't know how is your user_type field I assume it is "user_type"