diff --git a/README.md b/README.md index 6f2706d8..a368fafc 100644 --- a/README.md +++ b/README.md @@ -12,12 +12,14 @@ pip install pipenv pipenv install --dev pipenv shell python manage.py migrate -python manage.py createsuperuser npm install gulp build python manage.py runserver ``` +Open [http://127.0.0.1:8000](http://127.0.0.1:8000) and log in with the default +user name and password (admin/admin). + ## Development ### Fake data diff --git a/babybuddy/management/commands/migrate.py b/babybuddy/management/commands/migrate.py new file mode 100644 index 00000000..1bccb17f --- /dev/null +++ b/babybuddy/management/commands/migrate.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.contrib.auth.models import User +from django.core.management.commands import migrate + + +class Command(migrate.Command): + help = 'Creates an initial User (admin/admin) for Baby Buddy.' + + def handle(self, *args, **kwargs): + super(Command, self).handle(*args, **kwargs) + + superusers = User.objects.filter(is_superuser=True) + if len(superusers) == 0: + default_user = User.objects.create_user('admin', password='admin') + default_user.is_superuser = True + default_user.is_staff = True + default_user.save()