# Django Async & ASGI (Django) > ASGI vs WSGI, async views, sync_to_async, async_to_sync, limites ORM sync, performance async, database connection pooling - 26 questions d'entretien - Senior - [Questions d'entretien: Django](https://sharpskill.dev/fr/technologies/django/questions-entretien.md) ## 1. Quelle est la principale différence entre WSGI et ASGI ? **Réponse** ASGI (Asynchronous Server Gateway Interface) étend WSGI en ajoutant le support de la programmation asynchrone et des connexions persistantes comme les WebSockets. WSGI est synchrone et ne peut gérer qu'une requête à la fois par worker, tandis qu'ASGI permet de gérer plusieurs requêtes simultanément dans un seul processus grâce à l'event loop asyncio. ## 2. Comment déclarer une vue asynchrone en Django ? **Réponse** Une vue asynchrone en Django se déclare simplement en utilisant le mot-clé async devant def. Django détecte automatiquement si la vue est asynchrone et l'exécute dans l'event loop approprié. Cette syntaxe native de Python 3.5+ est pleinement supportée depuis Django 3.1. ## 3. Quel est le rôle de sync_to_async dans Django ? **Réponse** sync_to_async est un adaptateur fourni par asgiref qui permet d'exécuter du code synchrone dans un contexte asynchrone. Il enveloppe une fonction synchrone et l'exécute dans un thread pool séparé, évitant ainsi de bloquer l'event loop. C'est essentiel pour appeler l'ORM Django depuis une vue async car l'ORM est synchrone. ## 23 questions supplémentaires disponibles - Pourquoi l'ORM Django ne peut-il pas être utilisé directement dans une vue asynchrone ? - Quel est le rôle de async_to_sync dans Django ? 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é - [Authentification Django](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-authentication.md): 22 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 - [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-async-asgi