0

我的应用程序 (Django v 2.2.5) 正在使用 MySQL (MariaDB 10.4.6) 将数据存储在其数据库中,并完成并提交了所有迁移。它创建了超级用户,当我登录时,我可以创建所有相关的对象,但是Product(可以说是最重要的)没有被创建。我已经尝试更改模型,甚至删除BooleanField(唯一与正在存储的模型不同的唯一字段)并应用迁移,但它仍然不起作用。我什至删除了整个数据库并重新开始,希望绕过任何棘手的迁移,但这对我仍然没有任何帮助。这是我的models.py

class Partner(models.Model):
    name = models.CharField(max_length=150, blank=False, help_text="Enter the vendor name", verbose_name="Vendor name", unique=True)
    address = models.TextField(help_text="Enter the address of the vendor")
    formula = models.ForeignKey(Formula, on_delete = models.CASCADE)
    phone = PhoneNumberField(help_text="enter the vendor phone number")
    email = models.EmailField(max_length=254, help_text="Enter the vendor email address")
    photo = models.ImageField(upload_to="vendors")

    def __str__(self):
        return self.name
class ProductType(models.Model):
    name = models.CharField(max_length=150, blank=False, help_text="Enter the kind of product this is", verbose_name="Product type")

    def __str__(self):
        return self.name

class Product(models.Model):
    name = models.CharField(max_length=150, blank=False, help_text="Enter the name of the product", verbose_name="Product name")
    price = models.DecimalField(max_digits=12, decimal_places=5,\
         help_text="Enter the price of the product", \
             blank = False, default=0.0)
    product_type = models.ForeignKey(ProductType, on_delete = models.CASCADE)
    vendor = models.ForeignKey(Partner, on_delete = models.CASCADE)
    photo = models.ImageField(upload_to="products")


    def __str__(self):
        return self.vendor.name + ": " + self.name

我正在使用的任何字段或元数据参数是否不受支持?我对自己做错了什么感到迷茫。我试着查看日志,但看不到任何明显的东西可以为我指明正确的方向(我承认我不太擅长数据库)。这是错误日志:

InnoDB: using atomic writes.
2019-12-11 21:29:02 0 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
2019-12-11 21:29:02 0 [Note] InnoDB: Uses event mutexes
2019-12-11 21:29:02 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-12-11 21:29:02 0 [Note] InnoDB: Number of pools: 1
2019-12-11 21:29:02 0 [Note] InnoDB: Using SSE2 crc32 instructions
2019-12-11 21:29:02 0 [Note] InnoDB: Initializing buffer pool, total size = 16M, instances = 1, chunk size = 16M
2019-12-11 21:29:02 0 [Note] InnoDB: Completed initialization of buffer pool
2019-12-11 21:29:02 0 [Note] InnoDB: Starting crash recovery from checkpoint LSN=3370115
2019-12-11 21:29:03 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
2019-12-11 21:29:03 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2019-12-11 21:29:03 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2019-12-11 21:29:03 0 [Note] InnoDB: Setting file 'C:\xampp\mysql\data\ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2019-12-11 21:29:03 0 [Note] InnoDB: File 'C:\xampp\mysql\data\ibtmp1' size is now 12 MB.
2019-12-11 21:29:03 0 [Note] InnoDB: Waiting for purge to start
2019-12-11 21:29:03 0 [Note] InnoDB: 10.4.6 started; log sequence number 3370124; transaction id 2759
2019-12-11 21:29:03 0 [Note] InnoDB: Loading buffer pool(s) from C:\xampp\mysql\data\ib_buffer_pool
2019-12-11 21:29:03 0 [Note] Plugin 'FEEDBACK' is disabled.
2019-12-11 21:29:03 0 [Note] Server socket created on IP: '::'.

软件版本:

  • Python 3.6.4(v3.6.4:d48eceb,2017 年 12 月 19 日,06:54:40)[MSC v.1900 64 位 (AMD64)]
  • Django v 2.2.5
  • MariaDB 10.4.6
  • mysql客户端 1.4.4

我将非常感谢您能给我的任何帮助。

4

2 回答 2

1

不久前我有一个类似的问题。问题出在 MariaDB 10.4 上。

非常奇怪的是,可以从 django 应用程序的任何位置保存数据,但管理页面不起作用。例如,做一个

恢复到 MariaDB 5.5 解决了这个问题。

于 2020-01-29T16:47:17.803 回答
0

这些换行符在您的实际 python 代码中吗?我怀疑他们是,但如果是这样,他们不应该是。

于 2019-12-12T15:14:44.837 回答