Commit d13d3f53 authored by Aatish Neupane's avatar Aatish Neupane

create management command to create test users, use it in Docker

parent d3ade15c
......@@ -13,4 +13,4 @@ ADD requirements.txt /site/
RUN pip install -U -r /site/requirements.txt
COPY ./ /site
CMD bash -c 'python3 manage.py migrate --noinput && python3 manage.py collectstatic --noinput && uwsgi --ini=/site/uwsgi.ini'
\ No newline at end of file
CMD bash -c 'python3 manage.py migrate --noinput && python3 manage.py collectstatic --noinput && python3 manage.py create_test_users && uwsgi --ini=/site/uwsgi.ini'
docker build -t ipv6dotwork .
docker run -d -p 127.0.0.1:8001:8000 --name ipv6dotwork ipv6dotwork
sudo docker rm -f ipv6dotwork
sudo docker run -d -p 127.0.0.1:8001:8000 --env-file .env --name ipv6dotwork ipv6dotwork
\ No newline at end of file
from django.core.management import BaseCommand
from django.contrib.auth import get_user_model
User = get_user_model()
class Command(BaseCommand):
help = "Create test accounts. Don't use this in production!"
def handle(self, *args, **options):
user_fixture = [
{
'username': 'user1',
'email': 'user1@dev.ipv6.work',
'password': 'user1'
},
{
'username': 'user2',
'email': 'user2@dev.ipv6.work',
'password': 'user2'
},
]
for user_data in user_fixture:
User.objects.create_user(**user_data)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment