#27530: Referencing a function in a model field definition, and then removing 
that
reference (and function) after running a migration raises an exception
-----------------------------------------+------------------------
               Reporter:  Jesse          |          Owner:  nobody
                   Type:  Uncategorized  |         Status:  new
              Component:  Uncategorized  |        Version:  1.10
               Severity:  Normal         |       Keywords:
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  0
                  UI/UX:  0              |
-----------------------------------------+------------------------
 With a FileField you can define a function for the upload_to argument. If
 you reference a function within that field, and then decide to modify the
 field later by removing the function reference (and also the function),
 the migrations will cause the server to fail to start because it can't
 find the function that was previously referenced.

 For example:

 {{{
 def destination():
   return "path"

 ...

 file = models.FileField(upload_to=destination)
 }}}

 Then later on I decide I don't need the function

 {{{
 file = models.FileField(upload_to="hardcoded path")
 }}}

 Now whenever I try to run the server locally or do a migration, I get:
 "AttributeError: 'module' object has no attribute 'destination'". The only
 meaningful workaround is to delete all migrations

--
Ticket URL: <https://code.djangoproject.com/ticket/27530>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/052.1d4aa523023bfa97b661f8e509a78df8%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to