Skip to main content

Django accounts app

Project description

# MP-Accounts

Django accounts app.

### Installation

Install with pip:

```
pip install django-mp-accounts
```

Add accounts to urls.py:

```
urlpatterns += i18n_patterns(

path('account/', include('apps.accounts.urls')),

)
```

Add accounts to settings.py:
```
INSTALLED_APPS = [
'accounts',
]

LOGIN_REDIRECT_URL = '/'
```

### Profile model

models.py

```

from django.db import models
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.models import User


class UserProfile(models.Model):

user = models.OneToOneField(
User, related_name='profile', on_delete=models.CASCADE)

mobile = models.CharField(_('Mobile number'), max_length=255, blank=True)

address = models.CharField(_('Address'), max_length=255, blank=True)


@receiver(post_save, sender=User)
def save_profile(sender, instance, **kwargs):

if not hasattr(instance, 'profile'):
UserProfile.objects.create(user=instance)

```

urls.py

```
from accounts import urls


app_name = urls.app_name


urlpatterns = urls.urlpatterns + [
# Custom patterns
]
```

Run migrations:
```
$ python manage.py migrate
```

Project details


Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
django-mp-accounts-3.0.tar.gz (13.4 kB) Copy SHA256 hash SHA256 Source None Jul 1, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page