Giter VIP home page Giter VIP logo

django-visitor-information-middleware's Introduction

Django Visitor Information Middleware

This module contains a collection of middleware classes which make writing timezone and location aware applications easier.

Information provided by this middleware can be used to do things like:

  • Display a cookie consent message if visitor is coming from the country within the EU
  • Display timezone change notification if a user's location timezone doesn't match a timezone which is currently set in the profile
  • ...

Installation

bash

pip install django-visitor-information-middleware

Geolocation Database

To determine location information based on the user IP address, this module uses GEO IP database.

By default, it ships with a free GeoLite2 database (http://dev.maxmind.com/geoip/geoip2/geolite2/).

If you want to use a custom database file, simply set VISITOR_INFO_GEOIP_DATABASE_PATH setting to point to your geoip database file. Keep in mind that this file needs to be readable by a process under which your Django application is running.

Included Middleware

TimezoneMiddleware

The middleware activates a timezone for an authenticated user.

VisitorInformationMiddleware

This middleware adds the following keys to the request.visitor dictionary:

  • country - country the visitor is based in
  • city - city the visitor is based in
  • location.timezone - timezone used in the location visitor is based in
  • location.unit_system - unit system used in the location visitor is based in
  • user.timezone - timezone of the currently authenticated user
  • user.unit_system - unit system of the currently authenticated user.
  • cookie_notice - True if a cookie consent notice should be displayed for the current visitor.

Note: Location of the user is determined based on the user's IP address.

django-visitor-information-middleware's People

Contributors

kami avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.