Created
February 2, 2018 10:01
-
-
Save jmorenoamor/886915956136734c554c35c02ba0faf1 to your computer and use it in GitHub Desktop.
Create superuser in migration
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
from __future__ import unicode_literals | |
from django.db import models, migrations | |
from django.contrib.auth.models import User | |
def create_superuser(apps, schema_editor): | |
User.objects.create_superuser('admin', '[email protected]', 'admin') | |
def delete_superuser(apps, schema_editor): | |
User.objects.get(username="admin").delete() | |
class Migration(migrations.Migration): | |
dependencies = [ | |
('diet', '0001_initial'), | |
] | |
operations = [ | |
migrations.RunPython(create_superuser, delete_superuser), | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment