Django

Code

Ticket #7173: related_cache_r7513.patch

File related_cache_r7513.patch, 0.6 kB (added by gav, 2 weeks ago)

Patch from Travis Terry using related_name for the cache field name.

  • django/db/models/fields/related.py

    old new  
    165165    # SingleRelatedObjectDescriptor instance. 
    166166    def __init__(self, related): 
    167167        self.related = related 
    168         self.cache_name = '_%s_cache' % related.field.name 
     168        self.cache_name = '_%s_cache' % related.get_accessor_name() 
    169169 
    170170    def __get__(self, instance, instance_type=None): 
    171171        if instance is None: