#36622: FileField.__init__ is triggering storage LazyObject resolution at boot 
time
-------------------------------------+-------------------------------------
     Reporter:  Fabien MICHEL        |                    Owner:  (none)
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  5.2
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Clifford Gama):

 * resolution:  duplicate =>
 * status:  closed => new

Comment:

 Reopening because this issue can be fixed independently of #36504--it
 neither contradicts nor, strictly speaking, overlap. The reason being that
 for `override_settings` to work on custom storages, we still need to write
 a custom signal receiver. It only seems to work now because we're
 resolving for the first time after calling `override_settings`. However,
 whatever value is accessed will persist and cannot be overridden again.

 The following modification to the docs example should demonstrate:

 {{{#!python
 def test_storage(self):
     model = MyModel()
     self.assertIsInstance(model.upload.storage, FileSystemStorage)  #
 Assuming this is in settings
     with override_settings(
         STORAGES={
             "mystorage": {
                 "BACKEND": "django.core.files.storage.InMemoryStorage",
             }
         }
      ):
          self.assertIsInstance(model.upload.storage, InMemoryStorage)
 }}}
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36622#comment:5>
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 view this discussion visit 
https://groups.google.com/d/msgid/django-updates/01070199ca815529-25bd6373-394b-4eaf-823e-7c25aa02fa33-000000%40eu-central-1.amazonses.com.

Reply via email to