#29911: Standardize delete_cached_value API on model Fields
-------------------------------------+-------------------------------------
               Reporter:  Taylor     |          Owner:  nobody
  Hakes                              |
                   Type:  New        |         Status:  new
  feature                            |
              Component:  Database   |        Version:  2.1
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 I created a custom Django model field that is expensive to calculate and I
 store a cached value on the model. I am not able to clear the cache when
 some uses the refresh_from_db() method though, since there is no standard
 API to hook into it. It appears that there is a custom behavior for
 ForeignKey that calls the delete_cached_value function, if it detects it's
 a ForeignKey

 https://github.com/django/django/blob/master/django/db/models/base.py#L569

 It would be great to allow any custom Field to implement
 `delete_cached_value` and have it called inside refresh_from_db. What are
 your thoughts? I would be happy to submit a PR if this seems reasonable

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29911>
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/055.188907ccaa1d5a3bb97d8ca1fc498fe1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to