﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
24259	Django 1.7.4 makes the same migration change when `upload_to` and `validators` are set.	user0007	nobody	"My model:
{{{#!python
    from myapps.core.fstorages.util import get_upload_path
    from myapps.core.validators.base import FileValidator


    class Entry(models.Model):
        ....
        photo = models.ImageField(
            max_length=200,
            upload_to=get_upload_path,
            validators=[
                FileValidator(
                    allowed_extensions=['png', 'jpg'],
                    max_size=10 * 1024 * 1024,
                )
            ]
        )
}}}

Running makemigrations:

    $ python manage.py makemigrations entries

Migration:
{{{#!python
    class Migration(migrations.Migration):
        ...
        operations = [
            migrations.AlterField(
                model_name='entry',
                name='photo',
            field=models.ImageField(upload_to=myapps.core.fstorages.util.get_upload_path, max_length=200, verbose_name='photo', validators=[myapps.core.validators.base.FileValidator(allowed_extensions=[b'png', b'jpg'], max_size=10485760)]),
            preserve_default=True,
        ),
    ]
}}}
Running migrations

    $ python manage.py migrate entries
    OK


Running migrations (once again):

    $ python manage.py migrate entries
    Your models have changes that are not yet reflected in a migration, and so won't be applied. Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.

So I do:

    $ python manage.py makemigrations entries

and get the same migration. Every time I run makemigrations Django creates the same migration for field ""photo"" .. is there some bug?

Thanks.

PS. FileValidator and get_upload_path source:

{{{#!python
def get_upload_path(instance, filename):
    return ""/1/2/3""

@deconstructible
class FileValidator(object):
    def __init__(self, *args, **kwargs):
        self.allowed_extensions = kwargs.pop('allowed_extensions', ())
        self.allowed_mimetypes = kwargs.pop('allowed_mimetypes', ())
        self.min_size = kwargs.pop('min_size', 0)
        self.max_size = kwargs.pop('max_size', None)

    def __call__(self, value):
        # ...code here
        pass
}}}
"	Uncategorized	closed	Migrations	1.7	Normal	invalid	migrations		Unreviewed	0	0	0	0	0	0
