#29529: Allow FilePathField path to accept a callable.
-------------------------------------+-------------------------------------
     Reporter:  Sebastiaan Arendsen  |                    Owner:  nobody
         Type:  New feature          |                   Status:  new
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  migration,           |             Triage Stage:  Accepted
  filepathfield, makemigrations      |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  1                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

 * version:  2.0 => master
 * stage:  Unreviewed => Accepted
 * easy:  0 => 1


Comment:

 This seems a reasonable use-case: allow `FilePathField` to vary `path` by
 environment.

 The trouble with `os.path.join(...)` is that it will always be interpreted
 at import time, when the class definition is loaded. (The `(...)` say,
 ''...and call this...''.)

 The way to defer that would be to all `path` to accept a callable,
 similarly to how `FileField`'s `upload_to` takes a callable.

 * It should be enough to evaluate the callable in
 `FilePathField.__init__()`.
 * Experimenting with generating a migration looks good. (The operation
 gives `path` the fully qualified import path of the specified callable,
 just as with `upload_to`.)

 I'm going to tentatively mark this as ''Easy Pickings'': it should be
 simple enough.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29529#comment:4>
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.89615521fe69d4e1fbe3da8e9bdfcf3f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to