python - ValueError : invalid literal for int() with base 10: '' | Django

标签 python django error-handling

我正在使用 Django 来构建电子商务网络应用程序。我在 models.py 中编写了此代码

from django.db import models


# Create your models here.
class Product(models.Model):
    product_id = models.AutoField
    product_name = models.CharField(max_length=50)
    category = models.CharField(max_length=50, default="")
    subcategory = models.CharField(max_length=50, default="")
    price = models.IntegerField(default=0)
    desc = models.CharField(max_length=300)
    pub_date = models.DateField()
    image = models.ImageField(upload_to='mainShop/images', default="")

然后,我使用进行了 makemigrations
python manage.py makemigrations

产生了以下
D:\Projects\PyCharm Projects\VeroniCart\home>python manage.py makemigrations
No changes detected

然后我做了
python manage.py migrate

这给了我错误:
ValueError: invalid literal for int() with base 10: ''

我还要附加一个带有完整错误的log file
任何帮助表示赞赏!

最佳答案

问题已解决。我所做的就是从应用程序的迁移目录(除migrations/init.py除外)中删除了所有文件,并且从项目目录中删除了数据库文件 db.sqlite3
然后,我重复了前面的步骤(makemigrations和migration)。

Django再次创建了所有迁移文件和一个新的 db.sqlite3 文件,因此这对我有用。

关于python - ValueError : invalid literal for int() with base 10: '' | Django,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58133450/

相关文章:

asp.net - asp.net中的用户控件错误

java - 如何解决 “var cannot be resolved to a type”错误?

sql - Access 添加新行

python - 在另一个模板中显示来自 Django View 的 HTML 表格

python - 具有 Python C 扩展的类(不是方法)的完整和最小示例?

python - 为 BMP085 代码创建循环?

python - 检查成员值是否与之前迭代中的不同

python - 能够使用值返回嵌套字典? Django

python - 无法通过 python-jira lib 连接到 JIRA-api

python - 向现有 django 模型添加新的唯一字段时的最佳实践