问题
I have a model with CharField named oldName. I want to rename the field to newName.
When I run python manage.py makemigrations, I get a confirmation request "Did you rename model.oldName to model.newName (a CharField)? [y/N]"
However, I want to run the whole thing inside a docker container and there is no provision to provide the user input. Is there a way to force the migration without need for user input?
PS: I tried --noinput option with makemigrations. In this case migrations are not getting applied.
回答1:
Use
script_or_command < <(yes y)
But I'm not sure this will work for multiple input prompts.
来源:https://stackoverflow.com/questions/39866339/django-makemigrations-to-rename-field-without-user-input