mirror of https://github.com/snachodog/mybuddy.git
Override migrate command to create admin/admin user.
This commit is contained in:
parent
68d2e7f37c
commit
5fbf77e014
|
@ -12,12 +12,14 @@ pip install pipenv
|
||||||
pipenv install --dev
|
pipenv install --dev
|
||||||
pipenv shell
|
pipenv shell
|
||||||
python manage.py migrate
|
python manage.py migrate
|
||||||
python manage.py createsuperuser
|
|
||||||
npm install
|
npm install
|
||||||
gulp build
|
gulp build
|
||||||
python manage.py runserver
|
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
|
## Development
|
||||||
|
|
||||||
### Fake data
|
### Fake data
|
||||||
|
|
|
@ -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()
|
Loading…
Reference in New Issue