Django模型将无法验证或未安装

时间:2013-08-11 03:07:53

标签: django django-models

你能看出为什么我得到这个模型验证错误吗?

  • 我在MySQL中有一个名为“ paypal_transactions ”的表,其中包含记录。
  • 我正在尝试将此项目复制到具有现有数据库的另一台计算机上。

错误消息:

One or more models did not validate: store.purchase: 'paypal_transaction' has a
relation with model <class 'f3.paypal.models.PaypalPaymentTransactions'>, which 
has either not been installed or is abstract.

贝宝/ models.py

class PaypalPaymentTransactions(models.Model):

    class Meta:
        db_table = 'paypal_transactions'

    payment_id = models.CharField(max_length = 50)
    payer = models.CharField(max_length = 25)
    amount = models.DecimalField(decimal_places = 2, max_digits = 8,
                                 blank = True, default = "0.00")
    currency = models.CharField(max_length = 10)

商品/ models.py

from f3.paypal.models import PaypalPaymentTransactions

class Purchase(models.Model):

    user = models.ForeignKey(User, related_name = 'purchase_user')
    product = models.ForeignKey(Design)
    quantity = models.IntegerField()
    paypal_transaction = models.ForeignKey(
        PaypalPaymentTransactions,
        default = None,
        null = True,
        blank = True)

1 个答案:

答案 0 :(得分:2)

发生此错误可能是因为依赖性问题:

尝试使用这样的ForeignKey:

class Purchase(models.Model):

    user = models.ForeignKey(User, related_name = 'purchase_user')
    product = models.ForeignKey(Design)
    quantity = models.IntegerField()
    paypal_transaction = models.ForeignKey(
        'f3.paypal.PaypalPaymentTransactions',
        default = None,
        null = True,
        blank = True)