First of all I urge you to ask yourself this question before you begin "Why do I want to write my own authentication system?". Generally speaking there is little reason not to use either the built in django authentication system or an existing 3rd party library if you wish to use OAuth for example.
That said sometimes you do, and I indeed have had to once myself but I still used the django users table I just had to use different way of performing authentication and then used the login() function to programmatically log the user in afterwards.
Putting that aside from what you have described I do not see why you could not and indeed should not use the built in authentication system. You can extend the users table by creating a new model with a models.OneToOneField and then setup a post_save signal on the User model to automatically an instance of that new model (assuming it had no required attributes other than the foreign key.
If you wish to have custom registration forms then just create them as you would any other form and use Django's authentication system to authenticate them and then log them in - https://docs.djangoproject.com/en/3.0/topics/auth/default/#authenticating-users
Here's a very loose example of a user profile model that extends the user table to store the date of birth
Putting that aside from what you have described I do not see why you could not and indeed should not use the built in authentication system. You can extend the users table by creating a new model with a models.OneToOneField and then setup a post_save signal on the User model to automatically an instance of that new model (assuming it had no required attributes other than the foreign key.
If you wish to have custom registration forms then just create them as you would any other form and use Django's authentication system to authenticate them and then log them in - https://docs.djangoproject.com/en/3.0/topics/auth/default/#authenticating-users
Here's a very loose example of a user profile model that extends the user table to store the date of birth
class UserProfile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE, related_name="profile")dob = models.DateField(blank=True, null=True, verbose_name="Date Of Birth")
With this being an example of a signal that is used to ensure that a record is created when the user instance is saved
@receiver(post_save, sender=User)
def create_user_profile(sender, instance, created, **kwargs):
if created:
UserProfile.objects.create(user=instance)
On Monday, 3 February 2020 04:44:49 UTC, nrupesh08 wrote:
Hi,How to create multiple registration in django. and login also. without default django registeration and login form.my own and saparet registration table and login table . to authencation my own tables (registration and login).ex: registration table (id, name, email, mobile, date of birth, gender, password, profile pic) and leaterly, upload files an individual persons through registration id.plese tell me how do it? or reference code or links send me
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b3a6b1b7-cb75-43eb-9fe7-7734a937a22f%40googlegroups.com.
No comments:
Post a Comment