#29529: Allow FilePathField path to accept a callable. -------------------------------------+------------------------------------- Reporter: Sebastiaan Arendsen | Owner: Vasyl | Dizhak Type: New feature | Status: assigned Component: Database layer | Version: master (models, ORM) | Severity: Normal | Resolution: Keywords: migration, | Triage Stage: Accepted filepathfield, makemigrations | Has patch: 1 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 1 Easy pickings: 1 | UI/UX: 0 -------------------------------------+------------------------------------- Changes (by Clint Dunn):
* cc: Clint Dunn (added) Comment: I think that Nicolas Noe's solution, [https://github.com/django/django/pull/10299 PR], was correct. The model field can accept a callable as it is currently implemented. If you pass it a callable for the path argument it will correctly use that fully qualified function import path in the migration. The problem is when you go to actually instantiate a FilePathField instance, the FilePathField form does some type checking and gives you one of these {{{ TypeError: scandir: path should be string, bytes, os.PathLike or None, not function }}} This can be avoided by evaluating the path function first thing in the field form {{{__init__}}} function, as in the pull request. Then everything seems to work fine. -- Ticket URL: <https://code.djangoproject.com/ticket/29529#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 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/067.00b52aa0bd78c565d5a542dc22b91a36%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.