【发布时间】:2020-04-05 22:08:18
【问题描述】:
我的应用程序 (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
- mysqlclient 1.4.4
如果您能给予我任何帮助,我将不胜感激。
【问题讨论】:
-
“我点击保存但什么也没做”是什么意思?没有错误,没有页面重新加载?如果是这样,问题不在于您的数据库,而在于一个或多个字段中的无效数据
-
我的意思是当我点击保存按钮时它会加载但永远不会终止。我尝试输入无效数据进行控制,它向我显示了一条错误消息,但是当我修复错误时,它只是无限加载。
标签: python mysql django mariadb mariadb-10.4