#24823: FileField with callable default raise error  with forms
-------------------------------------+-------------------------------------
     Reporter:  Haussonne Yves-      |                    Owner:  nobody
  Marie                              |
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  1.8
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  needsinfo
     Keywords:  FileField, models,   |             Triage Stage:
  field                              |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Tai Lee):

 Just spent a few hours stepping through tracebacks trying to find out
 exactly what Django is doing here, before coming to the conclusion that it
 must be a Django bug and searching for an existing ticket.

 Perhaps I haven't read the documentation recently or thoroughly enough,
 but they don't seem that ambiguous regarding the behaviour of `default`
 specifically:

 {{{
 The default value for the field. This can be a value or a callable object.
 If callable it will be called every time a new object is created.
 }}}

 There's no special caveat for `FileField` and `ImageField` saying that
 callables cannot be used.

 Whether or not additional special handling of the evaluated default value
 (as per discussion on #17224) is ever implemented, that should not make
 any difference at all as to whether or not a callable can be used as a
 default.

 I think this ticket should be re-opened, and can and should be resolved
 much quicker and simpler than #17224, without much debate?

 It's valid to assign a string to a `FileField` (on an instance, or as a
 default value). Is there any reason why a callable that returns a string
 shouldn't be valid?

--
Ticket URL: <https://code.djangoproject.com/ticket/24823#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 [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/062.2e22fb65b4c928a80a0b8be918c0d4f7%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to