-
-
Save YPCrumble/a020ef9a3432ddf1134acce700c36ef0 to your computer and use it in GitHub Desktop.
Django 1.7+ migration for creating superuser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from __future__ import unicode_literals | |
from django.db import migrations | |
from django.contrib.auth.admin import User | |
def create_superuser(apps, schema_editor): | |
superuser = User() | |
superuser.is_active = True | |
superuser.is_superuser = True | |
superuser.is_staff = True | |
superuser.username = 'admin' | |
superuser.email = '[email protected]' | |
superuser.set_password('admin') | |
superuser.save() | |
class Migration(migrations.Migration): | |
dependencies = [ | |
] | |
operations = [ | |
migrations.RunPython(create_superuser) | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment