Monday, April 29, 2019

Re: about abstract user

Hi,

This is not a good way of building a Django user. 

To your questions:
1. AbstractUser is a class that implements some of the methods / properties that Django expects on a User model. See here : https://docs.djangoproject.com/en/2.2/topics/auth/customizing/#substituting-a-custom-user-model
The way this is implemented currently it is more like extending a user model - which you can read about here: https://docs.djangoproject.com/en/2.2/topics/auth/customizing/#extending-the-existing-user-model
But if you want to use AbstractUser as a base class, you shouldn't extend AbstractUser.
2. The AUTH_USER_MODEL is a setting in django that points to the current user model. Because you can change this via the substituting link above, you then need to set the correct user model in settings (which is set be the setting AUTH_USER_MODEL).

I would recommend that you read about the django custom user model for example here : https://wsvincent.com/django-custom-user-model-tutorial/

However I would go with creating a custom user model (if this is a new project).

Regards,

Andréas


Den mån 29 apr. 2019 kl 13:04 skrev sagar ninave <sagarninave@gmail.com>:
class User(AbstractUser):      tweet = models.ManyToManyField(Tweet, blank=True)      follower = models.ManyToManyField(settings.AUTH_USER_MODEL, blank=True)      pass    class Tweet(models.Model):      tweet = models.TextField()      favourite = models.ManyToManyField(settings.AUTH_USER_MODEL, blank=True, related_name='user_favourite')        def __unicode__(self):          return self.tweet


1) in above user model has passed AbbstractUser so what does it mean
2) also in follower field of User model ManyToManyField has setting.AUTH_USER_MODEL what does it mean

--
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4574d8ae-b0eb-4c4d-8f77-90b3be0a54ab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAK4qSCdAry8u1sNSCGzKPGVAUX_vJ_iKjT_Rxo-pLHt8pdiJ2g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment