#22436: migrations fail on custom upload_to on ImageField
-------------------------------------+-------------------------------------
     Reporter:  David Binetti        |                    Owner:
  <dbinetti@…>                       |  andrewgodwin
         Type:  Bug                  |                   Status:  assigned
    Component:  Migrations           |                  Version:
     Severity:  Release blocker      |  1.7-beta-2
     Keywords:                       |               Resolution:
    Has patch:  1                    |             Triage Stage:  Accepted
  Needs tests:  1                    |      Needs documentation:  0
Easy pickings:  0                    |  Patch needs improvement:  0
                                     |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by semenov):

 @Althalus, a very ugly workaround for this would be:

 {{{#!python
 # utils/files.py
 def gen_upload_to(fieldname, path, .......):
     import sys
     if len(sys.argv) > 1 and sys.argv[1] in ('makemigrations', 'migrate'):
         return None # Hide ourselves from Django migrations
     def upload_to(instance, filename):
         pass  # some custom logic
     return upload_to
 }}}

 Too bad Django monitors non-db-related field attributes for no apparent
 reason. It's not only upload_to. For instance, it creates a useless
 migration even when a field's `help_text` is changed.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/22436#comment:15>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/092.b339c7d2483a6f2fe473e3936b0c8a12%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to