Giter VIP home page Giter VIP logo

django-simple-accounts's Introduction

Django Simple Accounts

Stop rewriting User views and templates!

Use these views and templates to interact with the django.contrib.auth.models.User model. Allow your end users to easily login, logout, register, and manage their profile.

These views and templates are designed to be bear bones, not a lot of bells and whistles here.

Don't get bogged down managing Users, focus on writing your application!

Start using django-simple-accounts

  1. Install django-simple-accounts from GitHub using pip:

    pip install git+ssh://[email protected]/atheiman/django-simple-accounts.git@master

  2. Add the Django app accounts to INSTALLED_APPS in your settings file:

    # settings.py
    
    INSTALLED_APPS = (
       # ...
       'accounts',
    )
  3. Include the django-simple-accounts urls in your ROOT_URLCONF:

    # urls.py
    
    urlpatterns = patterns('',
        # ...
        url(r'^accounts/', include('accounts.urls', namespace='accounts')),
    )
  4. Create your UserProfile model if desired:

    # models.py
    
    class UserProfile(models.Model):
        user = models.OneToOneField(User)
        phone = models.CharField(
            max_length=12,
            blank=True,
        )
        # more model fields as needed
    
        def __unicode__(self):
            return self.user.username
  5. Configure django-simple-accounts in your settings:

    # settings.py
    
    DJANGO_SIMPLE_ACCOUNTS = {
        # python
        'USER_PROFILE_PYTHON_PATH': 'my_app.models.UserProfile',
    }

    Configuration is described completely below.

  6. Run the app and check it out:

    $ python manage.py makemigrations
    $ python manage.py migrate
    $ python manage.py runserver

    You should see Profiles as a StackedInline included in your admin site at /admin/auth/user/.

    The following URLs / views are also implemented for use:

Configuration

Configuration for django-simple-accounts is set in the django.settings.DJANGO_SIMPLE_ACCOUNTS dict. None of the keys are required to be set, however you must at least define the dict with no keys (DJANGO_SIMPLE_ACCOUNTS = {}).

Example configuration dict with all keys set:

# settings.py

DJANGO_SIMPLE_ACCOUNTS = {
    'USER_PROFILE_PYTHON_PATH': 'my_app.models.UserProfile',
}

An explanation of each key availble to be set is described below:

USER_PROFILE_PYTHON_PATH

Example: 'my_app.models.UserProfile'

Dotted python path to a subclass of django.db.models.Model that you have defined as a User Profile model as described in the Django docs. This setting allows:

  • an instance of the UserProfile model is created when a new User is created
  • the profile view includes fields for the UserProfile model

Notes:

  • Be sure to set Field.default or Field.blank and Field.null for all of your UserProfile model fields, because when the UserProfile instance is first created no fields will be set. Those fields are set from the profile view (after registration).

A note on URLs

As recommended above, it generally makes sense to include accounts.urls at `/accounts/. If you are going to place these at a different location, be sure to change the LOGIN_REDIRECT_URL, LOGIN_URL, and LOGOUT_URL described here.

Features to be added

[ ] User Profile Model management

[ ] Login with Google or Facebook

[ ] Register

[ ] Email registration confirmation link

[x] Configure with django settings

django-simple-accounts's People

Contributors

atheiman avatar

Stargazers

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

Watchers

 avatar  avatar  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.