Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

python - ValueError: Field 'id' expected a number but got 'Processing'

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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Just delete all the migration files except the init python file the run python manage.py makemigrations then python manage.py migrate


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...