loadAdminUser.py 453 Bytes
Newer Older
Florent Chehab's avatar
Florent Chehab committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
from django.contrib.auth.models import User


class LoadAdminUser(object):
    def __init__(self):
        admins = User.objects.filter(username="admin")
        if len(admins) > 0:
            self.admin = admins[0]

        else:
            self.admin = User.objects.create_superuser(
                username='admin',
                email='null@null.fr',
                password='admin'
            )

    def get(self):
        return self.admin