#22436: migrations fail on custom upload_to on ImageField
-------------------------------------+-------------------------------------
Reporter: David Binetti | Owner:
<dbinetti@…> | andrewgodwin
Type: Bug | Status: assigned
Component: Migrations | Version: master
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Althalus):
I'm using 1.7 now and found that migrations fail too my because upload_to
function is generated dynamically.
Consider the folloing example:
{{{
# utils/files.py
def gen_upload_to(fieldname, path, .......):
def upload_to(instance, filename):
pass # some custom logic
return upload_to
# app/models.py
class MyModel(models.Model):
file = models.FileField(upload_to=gen_upload_to('file',
'path/to/files'))
# app/migrations/0001_initial.py
class Migration(migrations.Migration):
operations = [
migrations.CreateModel(
name='MyModel',
fields=[
('file',
models.FileField(upload_to=utils.files.upload_to)),
],
),
]
}}}
Obviously my utils/files.py module doesn't contain `upload_to` function
with results in errors.
I had to create dummy `upload_to` in there to prevent import errors, but
anyway every time I use `makemigrations` command django detect changes in
my `file` field.
--
Ticket URL: <https://code.djangoproject.com/ticket/22436#comment:13>
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.47a600dfb354e35899fde4c76e1c0a68%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.