Replace fixtures by migrations.

This commit is contained in:
Antoine Nguyen
2015-01-29 12:17:02 +01:00
parent 9b3d00027f
commit 2d5f9eb462
7 changed files with 77 additions and 8 deletions
-1
View File
@@ -1 +0,0 @@
[{"pk": 1, "model": "core.user", "fields": {"username": "admin", "first_name": "", "last_name": "", "is_active": true, "is_superuser": true, "is_staff": false, "last_login": "2012-01-26T15:19:26+01:00", "groups": [], "user_permissions": [], "password": "{CRYPT}dTTsGDkA5ZHKg", "email": "", "date_joined": "2012-01-26T15:19:26+01:00"}},{"pk": 1, "model": "core.objectaccess", "fields": {"is_owner": true, "user": 1, "content_type": ["core", "user"], "object_id": 1}}]
@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
def load_initial_data(apps, schema_editor):
"""Load initial data."""
User = apps.get_model("core", "User")
user = User(username="admin", is_superuser=True)
user.set_password("password")
user.save()
ObjectAccess = apps.get_model("core", "ObjectAccess")
ObjectAccess.objects.create(user=user, content_object=user, is_owner=True)
class Migration(migrations.Migration):
dependencies = [
('core', '0001_initial'),
]
operations = [
migrations.RunPython(load_initial_data)
]
@@ -7,7 +7,7 @@ from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('core', '0001_initial'),
('core', '0002_load_initial_data'),
]
operations = [