matthiask / plata

Plata - the lean and mean Django-based Shop
https://plata-django-shop.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
197 stars 63 forks source link

Model validation error on syncdb #30

Closed Uznick closed 11 years ago

Uznick commented 11 years ago

Hi.

I add to settings.py according to the instructions: http://www.feinheit.ch/media/labs/plata/installation.html

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',

    'grappelli',
    'django.contrib.admin',

    'south',

    'vinny.apps.shop',

    'plata',
    'plata.contact', # Not strictly required (contact model can be exchanged)
    'plata.discount',
    'plata.payment',
    'plata.shop',
)

PLATA_SHOP_PRODUCT = 'vinny.apps.shop.models.Product'

And then I create the models in vinny.apps.shop.models.py:

# -*- coding:utf-8 -*-

from django.db import models
from django.utils.translation import ugettext_lazy as _

from plata.product.models import ProductBase
from plata.shop.models import PriceBase

class Product(ProductBase):
    name = models.CharField(_('name'), max_length=100)
    slug = models.SlugField(_('slug'), unique=True)
    description = models.TextField(_('description'), blank=True)

    class Meta:
        ordering = ['name']
        verbose_name = _('product')
        verbose_name_plural = _('products')

    def __unicode__(self):
        return self.name

    @models.permalink
    def get_absolute_url(self):
        return ('plata_product_detail', (), {'slug': self.slug})

class ProductPrice(PriceBase):
    product = models.ForeignKey(Product, verbose_name=_('product'),
        related_name='prices')

    class Meta:
        get_latest_by = 'id'
        ordering = ['-id']
        verbose_name = _('price')
        verbose_name_plural = _('prices')

When I run ./manage.py syncdb, I get an error: Error: One or more models did not validate: shop.orderitem: 'product' has a relation with model vinny.apps.shop.Product, which has either not been installed or is abstract.

Uznick commented 11 years ago

Am I right, that PLATA_SHOP_PRODUCT should direct to the Product model in my models.py?

How can I fix this error?

matthiask commented 11 years ago

Try adding PLATA_SHOP_PRODUCT = 'shop.Product' to your settings.py. Does that fix this issue? (PLATA_SHOP_PRODUCT uses Django's 'app_label.model_name' notation, not the python module path.)

Uznick commented 11 years ago

Yes, that works, thanks.