I have one model in my app running in a server with a few entries. I need to add a SlugField
, unique and not-null for this model. The SlugField
will be
You do your model changes (add field, change, etc), then you call manage.py makemigrations
, then apply the migrations with manage.py migrate
You can add the field with null=True
, then you e.g. make a script to populate it one time
Otherwise, if you need to populate the field within the migration you can write a custom one, see https://docs.djangoproject.com/en/1.7/ref/migration-operations/#writing-your-own
Unfortunatelly, I found no answer but I could create one solution: