Friday, January 29, 2016

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

Hi Markus,


Thank you very much, that solved the issue.

Many thanks,
Iliana



On Thursday, 28 January 2016 17:31:36 UTC-7, Markus Holtermann wrote:
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


On Friday, January 29, 2016 at 10:14:24 AM UTC+11, Iliana Toneva wrote:
 
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

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1c1ed33b-0838-4905-8d92-8007eca2ae18%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment