Created
November 21, 2014 07:44
-
-
Save edigiacomo/fdc5faef6cb0d06a3fe9 to your computer and use it in GitHub Desktop.
Automatic admin creation after `migrate` command in Django
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 django.dispatch import receiver | |
| from django.db import models | |
| from django.contrib.auth.models import User | |
| @receiver(models.signals.post_migrate) | |
| def create_superuser(sender, **kwargs): | |
| if not User.objects.filter(username='admin').first(): | |
| User.objects.create_superuser('admin', 'admin@localhost', 'admin') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment