Answer the question
In order to leave comments, you need to log in
How to fix migration error "ProgrammingError: column "file_id" cannot be cast automatically to type integer" django and postgres?
Hello, I've run into a strange problem.
models:
class Document(Model):
owner = models.ForeignKey('auth.User', verbose_name=u'Владелец')
title = models.CharField(verbose_name=u'Название', max_length=100)
description = models.CharField(verbose_name=u'Описание', max_length=1000, null=True, blank=True)
file_obj = models.ForeignKey('common.File', verbose_name=u'Файлы', blank=True, null=True)
def get_file_path(instance, filename):
ext = filename.split('.')[-1]
filename = "%s.%s" % (uuid.uuid4(), ext)
return os.path.join('files', filename)
class File(Model):
owner = models.ForeignKey('auth.User', verbose_name=u'Владелец')
name = models.CharField(verbose_name=u'Название', max_length=1000, null=True, blank=True)
file_storage = models.FileField(verbose_name=u'Сам файл', upload_to=get_file_path)
ProgrammingError: column "file_id" cannot be cast automatically to type integer
HINT: Specify a USING expression to perform the conversion.
Answer the question
In order to leave comments, you need to log in
The problems were in the migrations from the old base, I cleaned them up, the migrations started working.
Plus, for some reason postgres did not want to see the standard user, it said
relation "auth_user" does not exist
is solved by separate migrations:
python manage.py migrate auth
python manage.py migrate
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question