Snippet List
This middleware uses Django's Geoip support (https://docs.djangoproject.com/fr/2.2/ref/contrib/gis/geoip2/), as well as axes's package helper to retrieve IP address (since Django's REMOTE_ADDR might be wrong when behind a reverse proxy).
Ensure your geolite DB files are up to date (eg. with https://djangosnippets.org/snippets/10674/).
The checker is optional, but ensures that security is not broken due to a misspelled/missing GEOIP_COUNTRY_WHITELIST.
- middleware
- ip
- country
- geoip
- restriction
- blocker
This management command updates country and city Geolite databases from Maxmind (binary databases, not CSV ones), for use with Django's builtin Geoip utilities.
- maxmind
- management
- databases
- geoip
- python3
Use this to display an object on a page AND be able to process a form on this page.
This is just a copy of the [Django docs advice](https://docs.djangoproject.com/en/2.2/topics/class-based-views/mixins/#using-formmixin-with-detailview), but put as a reusable, standalone View.
Requires to install "basicauth" package, which does basic-auth header encoding/decoding cleanly according to RFCs.
Could be improved to return a "realm" in case of http401, like in https://djangosnippets.org/snippets/1720/, although I'm not sure it's really useful in django usecases.
- middleware
- basic
- authentication
- auth
- http-authorization
pakal has posted 4 snippets.