Opened 9 years ago

Last modified 9 years ago

#25866 new Cleanup/optimization

Django migrations not picking up max_length change on FileField — at Version 5

Reported by: Gerben Morsink Owned by: nobody
Component: Migrations Version: 1.7
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Gerben Morsink)

I have subclassed a FileField (call it S3storage) which first had no max_length

Now I changed max_length to 1000. Then running ./manage.py makemigrations it does not seems to be picked up.

The only thing I did was:

class S3FileField(models.FileField):
    def __init__(self, *args, **kwargs):
        super(S3PrivateFileField, self).__init__(*args, **kwargs)
        self.storage.default_acl = "private"

Change History (5)

comment:1 by Gerben Morsink, 9 years ago

Description: modified (diff)

comment:2 by Baptiste Mispelon, 9 years ago

Hi,

What you're describing seems to work for me (Django detects the change and writes a migration).

Could you show the full code of your model and custom field?

Thanks.

comment:3 by Gerben Morsink, 9 years ago

Ah, sorry! It works like I posted. But I wanted to do:

class S3PrivateFileField(models.FileField):
    def __init__(self, *args, **kwargs):
        if not kwargs.get('max_length',None):
            kwargs.update({'max_length':1000})
        super(S3PrivateFileField, self).__init__(*args, **kwargs)
        self.storage.default_acl = "private"

comment:4 by Gerben Morsink, 9 years ago

Description: modified (diff)

comment:5 by Gerben Morsink, 9 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top