Django

Django Sessions

Session framework, session backends, session middleware, session security, cookie-based vs database sessions

18 면접 질문·
Mid-Level
1

What is the main role of Django's session framework?

답변

Django's session framework allows storing and retrieving arbitrary data on a per-site-visitor basis on the server. It abstracts the process of sending and receiving session cookies, storing data server-side while only sending a session ID to the client via a cookie.

2

Which middleware must be enabled to use sessions in Django?

답변

SessionMiddleware is the middleware responsible for managing sessions in Django. It must be present in MIDDLEWARE for request.session to be available. This middleware reads and writes session data, managing the complete session lifecycle.

3

How to access session data in a Django view?

답변

Session data is accessed via request.session, which behaves like a Python dictionary. Reading, writing and deleting values works with standard dictionary syntax. Django automatically handles data serialization and persistence.

4

What is the default session backend in Django?

5

How to configure Django to use signed cookie-based sessions?

+15 면접 질문

다음 면접을 위해 Django을 마스터하세요

모든 질문, flashcards, 기술 테스트, 코드 리뷰 연습, 면접 시뮬레이터에 접근하세요.

무료로 시작하기