from django.db import models
from django.contrib.auth.models import User
class Student(models.Model):
rollno = models.CharField(max_length=13)
name = models.OneToOneField(User, on_delete=models.CASCADE)
dept = models.CharField(max_length=30)
def __str__(self):
return str(self.name)
class Subject(models.Model):
subname = models.CharField(max_length=50)
deptname = models.CharField(max_length=50)
def __str__(self):
return str(self.subname)
PS C:\Users\Akhil\Desktop\django\studentportal> python manage.py migrate Operations to perform: Apply all migrations: admin, auth, contenttypes, sessions, studentapp Running migrations: Applying studentapp.0003_auto_20210602_0944...Traceback (most recent call last): File "C:\Users\Akhil\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\models\fields_init_.py", line 1823, in get_prep_value return int(value) ValueError: invalid literal for int() with base 10: 'CSE'
我试图删除我创建的模型。无论何时尝试迁移模型,删除后都会出现此错误。因此,我再次添加了相同的模型主题
看起来您已经将数据库中的一个字段更改为
IntegerField
,然后再更改回来?如果可以擦除数据库,我建议删除它,并进行迁移,然后重新运行./manage.py makemigrations
和./manage.py migrate
相关问题 更多 >
编程相关推荐