Skip to content

Instantly share code, notes, and snippets.

@BenjiLee
Created June 22, 2017 18:18
Show Gist options
  • Save BenjiLee/e25b5b5aa4c319e7178accdf5d123503 to your computer and use it in GitHub Desktop.
Save BenjiLee/e25b5b5aa4c319e7178accdf5d123503 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.conf import settings
from django.contrib.auth import get_user_model
from django.db import migrations, models
class Migration(migrations.Migration):
def add_service_user(apps, schema_editor):
User = apps.get_model('core', 'User')
service_user = User.objects.create(
username=settings.ECOMMERCE_SERVICE_WORKER_USERNAME,
is_superuser=True
)
service_user.set_unusable_password()
service_user.save()
def remove_service_user(apps, schema_editor):
User = apps.get_model('core', 'User')
User.objects.get(username=settings.ECOMMERCE_SERVICE_WORKER_USERNAME).delete()
dependencies = [
('core', '0005_auto_20150924_0123'),
]
operations = [
migrations.RunPython(add_service_user, remove_service_user)
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment