- name, path, args, kwargs = super(EbookField, self).deconstruct()
- args.insert(0, self.format_name)
+ name, path, args, kwargs = super().deconstruct()
+ if kwargs.get('max_length') == 255:
+ del kwargs['max_length']
+ if kwargs.get('blank') is True:
+ del kwargs['blank']
+ if kwargs.get('default') == '':
+ del kwargs['default']
+ if self.get_upload_to(self.ext) == kwargs.get('upload_to'):
+ del kwargs['upload_to']
+ # with_etag creates a second field, which then deconstructs to manage
+ # its own migrations. So for migrations, etag_field_name is explicitly
+ # set to avoid double creation of the etag field.
+ if self.with_etag:
+ kwargs['etag_field_name'] = self.etag_field_name
+ else:
+ kwargs['with_etag'] = self.with_etag
+