Hello,
I have an issue trying to run tests.
My application use a migration to have default fixtures (created using migrations.RunPython from a migration file).
The problem is when I launch manage.py test, the fixtures from the migration are created on the "production" database and not on the test_* database.
Is there a way to solve this issue ? Is this a known issue or nobody has this problem ?
Here is the migration
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
def create_bars(apps, schema_editor):
Bar = apps.get_model("foo", "Bar")
db_alias = schema_editor.connection.alias
Bar
.objects.using(db_alias).bulk_create([
Bar
(label="AAA"),
Bar
(label="BBB")
])
class Migration(migrations.Migration):
dependencies = [
('
foo
', '0001_initial'),
]
operations = [
migrations.RunPython(
create_
bars
),
]
Thanks