Skip to main content

django account helper utils for `django.contrib.auth`

Project description

django account helper utils for django.contrib.auth


  • Django


pip install django_acocunt_helper


  1. check your, make sure django.contrib.auth in INSTALLED_APPS.

  2. add account_helper.middleware.CurrentUserMiddleware

config finish.

How to use

set current user as default value

update your model like this:


owner = models.ForeignKey(settings.AUTH_USER_MODEL)


from account_helper.middleware import get_current_user

# ... fields definition...

owner = models.ForeignKey(settings.AUTH_USER_MODEL, default=get_current_user)

set current user id as default value

update your model like this:


owner = models.IntegerField('user id')


from account_helper.middleware import get_current_user_id

# ... fields definition...

owner = models.IntegerField('user id',default=get_current_user_id)

Project details

Download files

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

Source Distribution

django-account-helper-0.1.3.tar.gz (1.6 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page