ValueError:字段"id"应为数字,但已得到“正在处理"

编程入门 行业动态 更新时间:2024-10-07 02:26:41
本文介绍了ValueError:字段"id"应为数字,但已得到“正在处理"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我要在DigitalOcean上部署django应用程序.一切顺利,除了以下错误,我的问题是:在哪里可以找到此错误的根源,实际上是在哪个文件中?

I'm going to deploy my django application on DigitalOcean. Everything gone well, except following error, and my question is: where can I find source of this error, actually in which file ?

Operations to perform: Apply all migrations: admin, auth, ccapp, contenttypes, sessions Running migrations: Applying ccapp.0009_auto_20191207_2148...Traceback (most recent call last): File "/home/progbash/ccproject/env/lib/python3.6/site-packages/django/db/models/fields/__init__.py", line 1768, in get_prep_value return int(value) ValueError: invalid literal for int() with base 10: 'Processing' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "manage.py", line 21, in <module> main() File "manage.py", line 17, in main execute_from_command_line(sys.argv) File "/home/progbash/ccproject/env/lib/python3.6/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line utility.execute() File "/home/progbash/ccproject/env/lib/python3.6/site-packages/django/core/management/__init__.py", line 395, in execute self.fetch_command(subcommand).run_from_argv(self.argv) ... File "/home/progbash/ccproject/env/lib/python3.6/site-packages/django/db/models/fields/__init__.py", line 2361, in get_db_prep_value value = self.get_prep_value(value) File "/home/progbash/ccproject/env/lib/python3.6/site-packages/django/db/models/fields/__init__.py", line 1772, in get_prep_value ) from e ValueError: Field 'id' expected a number but got 'Processing'.

models.py :

from datetime import datetime # Create your models here. class Question(models.Model): question_text = models.TextField(max_length=200) answer = models.TextField(max_length=200) def __str__(self): return self.question_text class ApplicantStatus(models.Model): class Meta: verbose_name_plural = "Applicant Statuses" name = models.CharField(max_length=30) def __str__(self): return self.name class Applicant(models.Model): name = models.CharField(max_length=20) surname = models.CharField(max_length=30) birth_date = models.DateField(blank=False) phone = models.CharField(max_length=15) email = models.EmailField(max_length=40) motivation_letter = models.TextField(max_length=200) status = models.ForeignKey(ApplicantStatus, on_delete=models.CASCADE, default=3) photo = models.FileField(upload_to='static/applicant_photos', blank=True) def __str__(self): return self.name class Message(models.Model): message_text = models.CharField(max_length=200) sender_name = models.CharField(max_length=30) sender_email = models.EmailField(max_length=50) def __str__(self): return self.sender_name

推荐答案

问题出在迁移文件中.我只是打开并将默认值从字符串类型更改为整数.

The problem was in migration files. I just opened and changed default value from string type to integer.

更多推荐

ValueError:字段"id"应为数字,但已得到“正在处理"

本文发布于:2023-11-26 21:49:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1635326.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字段   但已   数字   ValueError   id

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!