1

你能明白为什么我会收到这个模型验证错误吗?

  • 我在 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)
4

1 回答 1

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)
于 2013-08-11T13:24:47.727 回答