python - Django Migration InternalError 1054 未知列
问题描述
我在models.py中的现有项目中添加了一个ImageField,我运行了makeMigrations和Migrate,但是现在如果我转到我的管理面板,我会收到以下错误:
InternalError(1054, u"Unknown column 'activelisting.picture' in 'field list'")
如果我删除该 ImageField,此错误就会消失。
我正在运行 Django==1.11.26
这是该字段的副本:
picture = models.ImageField(null=True, blank=True, upload_to='images/')
非常感谢对此的任何帮助。
编辑:之前应该提到过这一点,但它在 MariaDB 上运行。
管理员.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from listings.models import *
from django.contrib import admin
# Register your models here.
def make_active(modeladmin, request, queryset):
queryset.update(active=True)
make_active.short_description = "Activate selected listings"
def make_inactive(modeladmin, request, queryset):
queryset.update(active=False)
make_inactive.short_description = "Inactivate selected listings"
class ListingAdmin(admin.ModelAdmin):
#readonly_fields = ['picture']
list_display = ('address', 'active', 'number_br', 'number_bath', 'owner', 'city',)
list_filter = ('active', 'owner',)
ordering = ('-active','address',)
actions = [make_active, make_inactive,]
admin.site.register(Activelisting, ListingAdmin)
admin.site.disable_action('delete_selected')
模型.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models
# Create your models here.
class Activelisting(models.Model):
active = models.BooleanField(default=False)
owner = models.CharField(max_length=60, blank=True, null=True)
address = models.CharField(max_length=100, blank=True, null=True)
city = models.CharField(max_length=100, blank=True, null=True)
house_types = (('house', 'House'), ('apartments', 'Apartments'), ('mobile', 'Mobile home'), ('duplex', 'Duplex'), )
housing_type = models.CharField(max_length=10, choices=house_types, default='house')
br_types = ( (1, '1'), (2, '2'), (3, '3'), (4, '4'), (5, '5'), )
bath_types = ( (1, '1'), (2, '2'), (3, '3'), (4, '4') )
number_br = models.IntegerField(choices=br_types, default=1)
number_bath = models.IntegerField(choices=bath_types, default=1)
description = models.TextField(blank=True, null=True)
#picture = models.ImageField(null=True, blank=True, upload_to='images/')
class Meta:
managed = False
db_table = 'activelisting'
解决方案
推荐阅读
- ios - Xcode 12.2:调试器不使用断点
- sqlite - Row_Number() 函数在 sqlite 版本 3.5.1 中不起作用
- javascript - vue.js 中的动态背景图片
- python - 在 macOS BigSur 上使用自制 python 安装 numpy 的问题
- assembly - 终端打印一个“?” x86减法运算中的字符
- nginx - 在 CentOS 7.9 中安装 epel 后没有可用的软件包 nginx
- php - 处理多种场景运费计算和数据存储
- java - Java逻辑错误:继续运行相同的菜单
- reactjs - 如何创建嵌套组件?
- c# - 如何使用返回的 cookie 发出获取请求?