我想将ImageField添加到我的模型名称"models"中,但是管理面板失败了.... 我是初学者...我的失败是我知道的非常基本的例外,但我无法解决。
我该怎么办? (对不起,我的英语不好,我是高中生(
型号代码
from django.db import models
# Create your models here.
#create a model and some models
class posting (models.Model):
title=models.CharField(max_length=120,verbose_name='Başlık')
content=models.TextField(verbose_name="İçerik")
publishing_date=models.DateTimeField(verbose_name="Yayınlanma tarihi")
photo=models.ImageField()
#herposta title ına göre indexliyor
def __str__(self):
return self.title
异常描述:
OperationalError at /admin/posting/posting/
no such column: posting_posting.photo
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/posting/posting/
Django Version: 1.10
Exception Type: OperationalError
Exception Value:
no such column: posting_posting.photo
Exception Location: C:UsersLenovoDesktopblogvenvlibsite-packagesdjangodbbackendssqlite3base.py in execute, line 337
Python Executable: C:UsersLenovoDesktopblogvenvScriptspython.exe
Python Version: 3.7.0
Python Path:
['C:\Users\Lenovo\Desktop\blog',
'C:\Users\Lenovo\Desktop\blog\venv\Scripts\python37.zip',
'C:\Users\Lenovo\Desktop\blog\venv\DLLs',
'C:\Users\Lenovo\Desktop\blog\venv\lib',
'C:\Users\Lenovo\Desktop\blog\venv\Scripts',
'c:\users\lenovo\appdata\local\programs\python\python37-32\Lib',
'c:\users\lenovo\appdata\local\programs\python\python37-32\DLLs',
'C:\Users\Lenovo\Desktop\blog\venv',
'C:\Users\Lenovo\Desktop\blog\venv\lib\site-packages']
Server time: Sal, 14 Ağu 2018 02:01:09 +0300`enter code here`
最有可能的是,您仍然需要创建一个数据库迁移manage.py makemigrations
,然后在manage.py migrate
运行它。