Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

Authentication provider for Solarlux Auth Service.

Project description

Consult the django-project-template on how to use it.

Upgrade from 1.7 to 1.8

In 1.8 there is a new username column introduced which removes unique identification responsibility from the email column. To migrate existing users and populate the DB sucessfully add the following script to your migrations. Fix the model name as needed and update the dependency to the last previous migration.

Afterwards run makemigrations as usual to update other fields.

populate username migration:

import django.contrib.auth.validators
from django.db import migrations, models
from django.db.models import Count


def populate_usernames(apps, schema_editor):
        User = apps.get_model('app', 'User')

        for grp in User.objects.exclude(um_id__isnull=True).values('um_id').annotate(ct=Count('um_id')):
                if grp['ct'] > 1:
                        User.objects.filter(um_id=grp['um_id']).update(um_id=None)

        for u in User.objects.all():
                if u.um_id:
                        u.username = 'um_%s' % u.um_id
                else:
                        u.username = 'user_%s' % u.id
                u.save()


class Migration(migrations.Migration):

        dependencies = [
                ('app', '0009_auto_20180208_1339'),
        ]

        operations = [
                migrations.AddField(
                        model_name='user',
                        name='username',
                        field=models.CharField(null=True,
                                                                   help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.',
                                                                   max_length=150, unique=False,
                                                                   validators=[django.contrib.auth.validators.UnicodeUsernameValidator()],
                                                                   verbose_name='username'),
                ),
                migrations.RunPython(populate_usernames),
                migrations.AlterField(
                        model_name='user',
                        name='username',
                        field=models.CharField(error_messages={'unique': 'A user with that username already exists.'},
                                                                   help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.',
                                                                   max_length=150, unique=True,
                                                                   validators=[django.contrib.auth.validators.UnicodeUsernameValidator()],
                                                                   verbose_name='username'),
                )
        ]

Project details


Release history Release notifications

This version
History Node

1.9.0

History Node

1.8.2

History Node

1.8.1

History Node

1.8.0

History Node

1.7.0

History Node

1.6.16

History Node

1.6.15

History Node

1.6.14

History Node

1.6.13

History Node

1.6.12

History Node

1.6.11

History Node

1.6.10

History Node

1.6.9

History Node

1.6.8

History Node

1.6.7

History Node

1.6.6

History Node

1.6.5

History Node

1.6.4

History Node

1.6.3

History Node

1.6.2

History Node

1.6.1

History Node

1.6.0

History Node

1.5.1

History Node

1.5.0

History Node

1.4.9

History Node

1.4.8

History Node

1.4.7

History Node

1.4.6

History Node

1.4.5

History Node

1.4.4

History Node

1.4.3

History Node

1.4.2

History Node

1.4.1

History Node

1.4.0

History Node

1.3.1

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-slxauth-1.9.0.tar.gz (14.2 kB) Copy SHA256 hash SHA256 Source None Jun 19, 2018

Supported by

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