#22436: migrations fail on custom upload_to on ImageField
-------------------------------------+-------------------------------------
Reporter: David Binetti | Owner:
<dbinetti@…> | chriscauley
Type: Bug | Status: assigned
Component: Migrations | Version:
Severity: Normal | 1.7-beta-1
Keywords: | Resolution:
Has patch: 0 | Triage Stage: Accepted
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by chriscauley):
Your specific problem can be easily fixed by moving the upload_thumb
method outside of the Photo class. Unless call Photo.upload_thumb anywhere
there's no difference between the two. There's nothing wrong with how you
did it before, but there's no way to implement migrations with as you had
it (except manually typing qualname for Photo.upload_to like you did).
I'll expand on this in a second comment, but for now here's your solution.
{{{
def upload_thumb(instance, filename):
return 'photos/{0}/dropbox{1}'.format(instance.account.id, filename)
class Photo(models.Model):
account = models.ForeignKey(Account)
...
thumbnail = models.ImageField(upload_to=upload_thumb, null=True)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/22436#comment:3>
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.151880ea243255843e1a85f2b3881786%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.