kabanzzzik
kabanzzzik

Reputation: 21

django-oscar RuntimeError: conflicting models

Version Info: Python 2.7, Django 1.9, Oscar Commerce - VERSION = (1.3)

I am trying to customize Products and few other models in the catalogue app following the documentation.

I have forked catalogue app (to myproject/forked_apps/catalogue) as per documentation documentation and did this in models.py:

from django.db import models
from oscar.apps.catalogue.abstract_models import AbstractProduct

class Product(AbstractProduct):
    is_active = models.BooleanField(default=False)

from oscar.apps.catalogue.models import *

I have already included the modified catalogue app, in the INSTALLED_APPS in settings.py as an argument for get_core_apps function, as stated in docs (so my local app is replacing the original app from Oscar).

INSTALLED_APPS = [
   ...
] + get_core_apps(['forked_apps.catalogue'])

Migrations are also copied from oscar.apps.catalogue to my local app. When I'm trying to make migrations I'm getting this error all the time:

RuntimeError: Conflicting 'product_product_options' models in application 'catalogue': <class 'oscar.apps.catalogue.models.Product_product_options'> and <class 'forked_apps.catalogue.models.Product_product_options'>.

I tried to remove all migrations from my local catalogue app (the I copied before from Oscar app), then it works, but all new migrations are created in Oscar source code folder, but I need them to be in my project...

How do I get over this error ?

Upvotes: 2

Views: 903

Answers (1)

Raydel Miranda
Raydel Miranda

Reputation: 14360

Make sure you're using the following wherever you use the Product model:

from oscar.core.loading import get_model

Product = get_model('catalogue', 'Product')

if you, in some place of your code write an import just like this:

from oscar.apps.catalogue.models import Product

you will ran into this issue.

Upvotes: 0

Related Questions