proxy model inheritance generates a migration file in a third party app

162 views
Skip to first unread message

Iliana Toneva

unread,
Jan 28, 2016, 6:14:24 PM1/28/16
to Django users
 
Hello,

I am using a third party app actstream (https://github.com/justquick/django-activity-stream) and am creating a proxy for one of the original actstream models :

# myapp/models.py
from actstream.models import Action
# Subclass Action model and apply my own manager 
class MyAction(Action):
objects = MyActionManager()

class Meta:
proxy = True
app_label = 'actstream'

The issue that I am having is that when I run './manage.py makemigrations', that creates a migration file 0002_myaction.py and adds it to the third party app migrations (instead of adding it to myapp/migrations):

Migrations for 'actstream':

  0002_myaction.py:

    - Create proxy model MyAction


# actstream/migrations/0002_myaction.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('actstream', '0001_initial'),
]

operations = [
migrations.CreateModel(
name='MyAction',
fields=[
],
options={
'proxy': True,
},
bases=('actstream.action',),
),
]
Is there a way to prevent this behavior and force './manage.py makemigrations' to create a migration file in myapp/migrations/ instead? 

Many thanks,
Iliana

Markus Holtermann

unread,
Jan 28, 2016, 7:31:36 PM1/28/16
to Django users
Hello Iliana,

this is due to the definition of app_label = 'actstream' on your proxy model. This tells Django that this model should belong to another app. Hence the migrations involving that model are added to the actstream app's migrations.

/Markus

Iliana Toneva

unread,
Jan 29, 2016, 11:36:52 AM1/29/16
to Django users
Hi Markus,


Thank you very much, that solved the issue.

Many thanks,
Iliana
Reply all
Reply to author
Forward
0 new messages