[Django] #25088: Migrations fail when change upload_to from function to sting type

11 views
Skip to first unread message

Django

unread,
Jul 9, 2015, 2:11:51 AM7/9/15
to django-...@googlegroups.com
#25088: Migrations fail when change upload_to from function to sting type
-------------------------------+------------------------
Reporter: argaliev | Owner: nobody
Type: Uncategorized | Status: new
Component: Migrations | Version: 1.8
Severity: Normal | Keywords: Migrations
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------
In first migration function make_upload_path was passed to upload_to
property of FIleField:
{{{
def make_upload_path(instance, filename):
return 'auto_scripts/{0}/{1}'.format(instance.id,filename)

class file_imports(models.Model):
orig_file = models.FileField(upload_to=make_upload_path, blank=True,
null=True)
}}}
Then upload_to was changed to hardcoded string and function
make_upload_path was deleted.

{{{
orig_file = models.FileField(upload_to='auto_scripts/', blank=True,
null=True)
}}}
and getting following error when starting makemigrations:
{{{
......
File "...../main/migrations/0001_initial.py", line 108, in Migration
('orig_file', models.FileField(upload_to=main.models.make_upload_path,
null=True,
AttributeError: 'module' object has no attribute 'make_upload_path'
}}}

Looks like migrations still want to see old function make_upload_path in
code, but it does't need anymore.

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

Django

unread,
Jul 9, 2015, 6:35:25 AM7/9/15
to django-...@googlegroups.com
#25088: Migrations fail when change upload_to from function to sting type
-------------------------------+--------------------------------------
Reporter: argaliev | Owner: nobody
Type: Uncategorized | Status: closed
Component: Migrations | Version: 1.8
Severity: Normal | Resolution: invalid

Keywords: Migrations | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by timgraham):

* status: new => closed
* needs_better_patch: => 0
* resolution: => invalid
* needs_tests: => 0
* needs_docs: => 0


Comment:

You need to keep the `make_upload_path()` function around as long as it's
referenced in migrations. See
https://docs.djangoproject.com/en/stable/topics/migrations/#historical-
models.

--
Ticket URL: <https://code.djangoproject.com/ticket/25088#comment:1>

Reply all
Reply to author
Forward
0 new messages