I don't want to create a migration file whenever I change the storage of the FileField. I am getting the storage class from settings.py and it is configurable.
settings.py
Storage = S3BotoStorage(bucket='example')
models.py
from django.conf import settings
class myModel(models.Model):
file = models.FileField(upload_to='', blank=True, storage=settings.Storage)
TLDR: It's an empty migration, it's harmless let it be reading any further or trying different things is probably just a waste of time
When ever you make a change to a model django has to make a migration because it needs to keep track of what changes have been made to a model over time. However that does not always mean that a modification will be made in the database. The migration produced here is an empty one. Your migration probably looks something like this and you will say, hay that's not empty!!
class Migration(migrations.Migration):
dependencies = [
('stackoverflow', '0010_jsonmodel'),
]
operations = [
migrations.AlterField(
model_name='jsonmodel',
name='jfield',
field=stackoverflow.models.MyJsonField(),
),
migrations.AlterField(
model_name='parent',
name='picture',
field=models.ImageField(storage=b'Bada', upload_to=b'/home/'),
),
]
But it is!! just do
./manage.py sqlmigrate <myapp> <migration_number>
And you will find that it does not produce any SQL! Quote from the manual as suggested by @sayse
Django will make migrations for any change to your models or fields - even options that don’t affect the database - as the only way it can reconstruct a field correctly is to have all the changes in the history, and you might need those options in some data migrations later on (for example, if you’ve set custom validators).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With