S
S
Sergey Nizhny Novgorod2016-10-13 07:11:18
Django
Sergey Nizhny Novgorod, 2016-10-13 07:11:18

How to fix an error when trying to migrate (alter) a database?

Hello.
I'm trying to change one field in the model now, the migration gives me an error that the arguments are not accepted.
It was:

author = models.CharField(max_length=65, help_text="ФИО автора",  verbose_name="Имя Автора")

I'm trying to do:
author = models.ForeignKey(Author, on_delete=models.CASCADE, blank=True, null=True)

Author model:
class Author(models.Model):
    author_image = models.ImageField(upload_to='', blank=True, null=True, help_text="Размер изображения 100 * 100",
                                     verbose_name="Фотография автора")
    name = models.CharField(max_length=150, help_text="Максимальная длина 150 символов", verbose_name="Имя автора")
    description = models.TextField(help_text="Кто такой автор, что делает автор, что он умеет",
                                   verbose_name="Описание автора")

===
i.e. I completely change the type of the field, I change the type of data that this field accepts.
P.S. Google search turned up nothing.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Kuts, 2016-10-13
@Terras

Well, create two migrations. One deletes the field, the other creates a new one.

Z
zelsky, 2016-10-13
@zelsky

Delete all files in the migrations folder in the app except init and try again

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question