# Authentification Django (Django) > User model, authentication backend, login/logout, permissions, groups, custom user model - 22 questions d'entretien - Confirmé - [Questions d'entretien: Django](https://sharpskill.dev/fr/technologies/django/questions-entretien.md) ## 1. Quel modèle Django utiliser par défaut pour représenter les utilisateurs dans une application ? **Réponse** Le modèle User de django.contrib.auth.models est le modèle par défaut pour gérer les utilisateurs dans Django. Il fournit des champs essentiels comme username, password, email, first_name, last_name, et des méthodes d'authentification intégrées. Ce modèle est automatiquement disponible après avoir ajouté django.contrib.auth dans INSTALLED_APPS. ## 2. Quelle fonction Django permet de vérifier les identifiants d'un utilisateur et retourner l'objet User correspondant ? **Réponse** La fonction authenticate() de django.contrib.auth prend en paramètre les identifiants (généralement username et password) et vérifie leur validité auprès des backends d'authentification configurés. Elle retourne l'objet User si les identifiants sont corrects, ou None si l'authentification échoue. Cette fonction ne connecte pas l'utilisateur, elle valide seulement les credentials. ## 3. Quelle fonction utiliser pour créer une session et connecter un utilisateur après authentification réussie ? **Réponse** La fonction login() de django.contrib.auth prend en paramètre la request et l'objet User authentifié pour créer une session. Elle stocke l'ID de l'utilisateur dans la session et associe le backend d'authentification utilisé. Cette fonction doit être appelée après authenticate() pour compléter le processus de connexion. ## 19 questions supplémentaires disponibles - Comment déconnecter un utilisateur et invalider sa session dans Django ? - Quel décorateur Django permet de restreindre l'accès à une vue aux utilisateurs connectés ? S'inscrire gratuitement: https://sharpskill.dev/fr/login ## Autres sujets d'entretien Django - [Les bases de Python](https://sharpskill.dev/fr/technologies/django/questions-entretien/python-basics.md): 25 questions, Junior - [Python orienté objet](https://sharpskill.dev/fr/technologies/django/questions-entretien/python-oop.md): 20 questions, Junior - [Fondamentaux Django](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-fundamentals.md): 20 questions, Junior - [Models Django - Bases](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-models-basics.md): 22 questions, Junior - [Vues Django](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-views.md): 20 questions, Junior - [Templates Django](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-templates.md): 18 questions, Junior - [Formulaires Django](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-forms.md): 22 questions, Confirmé - [QuerySets avancés](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-querysets.md): 25 questions, Confirmé - [Middleware Django](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-middleware.md): 18 questions, Confirmé - [Admin Django](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-admin.md): 20 questions, Confirmé - [Django REST Framework](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-rest-framework.md): 30 questions, Confirmé - [Signaux Django](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-signals.md): 18 questions, Confirmé - [Upload de fichiers](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-file-upload.md): 20 questions, Confirmé - [Cache Django](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-caching.md): 20 questions, Confirmé - [Sessions Django](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-sessions.md): 18 questions, Confirmé - [Email Django](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-email.md): 18 questions, Confirmé - [Tests Django](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-testing.md): 22 questions, Confirmé - [Sécurité Django](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-security.md): 22 questions, Confirmé - [Déploiement Django](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-deployment.md): 24 questions, Confirmé - [ORM Django avancé](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-orm-advanced.md): 28 questions, Senior - [Performance Django](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-performance.md): 24 questions, Senior - [Django & Celery](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-celery.md): 22 questions, Senior - [Django Channels](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-channels.md): 24 questions, Senior - [Django & GraphQL](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-graphql.md): 24 questions, Senior - [Django & Docker](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-docker.md): 20 questions, Senior - [Django dans un écosystème Microservices](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-microservices.md): 24 questions, Senior - [Commandes Django personnalisées](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-custom-commands.md): 18 questions, Senior - [Internationalisation Django](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-internationalization.md): 20 questions, Senior - [Design Patterns Django](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-design-patterns.md): 24 questions, Senior - [Django Async & ASGI](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-async-asgi.md): 26 questions, Senior - [Settings & Configuration Production](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-settings-configuration.md): 22 questions, Senior - [Observabilité & Monitoring](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-observability.md): 24 questions, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/fr/technologies/django/questions-entretien/django-authentication