Good day!

Tell me, please, how correctly in the model to associate the field with the native Django auth_user table (so that when added to the database, the user id is recorded).

And is it worth using Django's native authorization and registration if it fits the project or is it better to do something of your own?

    1 answer 1

    Associating objects with the user is elementary - user = models.ForeignKey('auth.user') ; in recent versions of Django, it’s easy to make your own user model, but if you are comfortable with the standard one, take it to start.

    • user = models.ForeignKey ('auth.user') user_id = models.ManyToManyField (user, related_name = '+') I do this, but the server says that ManyToManyField requires a model name or self. I already wrote user in '' and just 'auth.user', but he still swears. - balalay
    • 'auth.User', sorry, wrong. The class of the model with the capital is written. - ravli
    • Thank you, earned! I'll know. - balalay