Skip to main content
Join the official Python Developers Survey 2018 and win valuable prizes: Start the survey!

Stores the user's information in the session, reucing database queries by a lot.

Project description


This app is a simple piece of middleware that can be added to your Django
project which will store and retrieve the logged-in user's information from
the session.


Add the sesionuser middleware line to your MIDDLEWARE_CLASSES after the

# ...
# ...

Why do this?

Your server is already fetching the contents of the user's session, which
already contains the user's identity. Why not store the rest of the user
class's data along with it? That way you don't have to make a request to the
database for every authenticated web request.

Additionally if you are using a cookie-based session backend (like
django-cookie-sessions, written by yours truly) you can have other systems,
maybe even non-Django systems, which read the cookie and know more information
about the user.

Customizable Settings


The number of seconds that need to elapse before the user is fetched from
the database instead of trusting the cookie. This is useful for making
sure that even if the user's properties are changed in the database,
the user's cookie will still be updated.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
django-session-user-0.1.1.tar.gz (3.8 kB) Copy SHA256 hash SHA256 Source None Jun 9, 2011

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page