This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

django account helper utils for django.contrib.auth

Requirement

  • Django1.8+

Install

pip install django_acocunt_helper

Config

  1. check your settings.py, 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:

before

owner = models.ForeignKey(settings.AUTH_USER_MODEL)

after

from account_helper.middleware import get_current_user

# ... fields definition...

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

set current user id as default value

update your model like this:

before

owner = models.IntegerField('user id')

after

from account_helper.middleware import get_current_user_id

# ... fields definition...

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

use session in form

sometimes we really need handle session in form. but in django. we have to do something like this.

old style

  1. in your views. set get_form_kwargs
class YourFormView(FormView):
    form_class=YourForm
    def get_form_kwargs(self):
        return {'request':self.request}
        pass

    pass

2.set your form.

Class YourForm(forms.Form):
    request = None

    def __init__(self,*args,**kwargs):
        self.request = kwargs.get('request')
        if 'request' in kwargs:
            del kwargs['request']
        super (YourForm,self).__init__(*args,**kwargs)

do it in django-account-helper

from account_helper.middleware import get_current_session

Class YourForm(forms.Form):

    def clean(self):
        session = get_current_session()
        if self.cleaned_data.get('foo') == session.get('foo'):
            # do something
            pass

        #... your code
    pass

create need authorized classed-view

from account_helper.mixins import LoginDispatchMixin

class GenericListingView(LoginDispatchMixin, TemplateView):
    template_name = 'accounts/profile.html'
    pass
Release History

Release History

0.1.5

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.4

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-account-helper-0.1.5.tar.gz (2.3 kB) Copy SHA256 Checksum SHA256 Source Sep 27, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting