Ticket #17814: concept.patch
File concept.patch, 1.9 KB (added by , 13 years ago) |
---|
-
db/models/related.py
1 1 from django.utils.encoding import smart_unicode 2 2 from django.db.models.fields import BLANK_CHOICE_DASH 3 from django.conf import settings 3 4 4 5 class BoundRelatedObject(object): 5 6 def __init__(self, related_object, field_mapping, original): … … 57 58 # accessor descriptor that retrieves related many-to-one or 58 59 # many-to-many objects. It uses the lower-cased object_name + "_set", 59 60 # but this can be overridden with the "related_name" option. 61 related_name_override = settings.RELATED_NAME_OVERRIDES.get('%s.%s.%s' % (self.opts.app_label, self.opts.module_name, self.field.name), None) 60 62 if self.field.rel.multiple: 61 63 # If this is a symmetrical m2m relation on self, there is no reverse accessor. 62 64 if getattr(self.field.rel, 'symmetrical', False) and self.model == self.parent_model: 63 65 return None 64 return self.field.rel.related_name or (self.opts.object_name.lower() + '_set')66 return related_name_override or self.field.rel.related_name or (self.opts.object_name.lower() + '_set') 65 67 else: 66 return self.field.rel.related_name or (self.opts.object_name.lower())68 return related_name_override or self.field.rel.related_name or (self.opts.object_name.lower()) 67 69 68 70 def get_cache_name(self): 69 71 return "_%s_cache" % self.get_accessor_name() -
conf/global_settings.py
235 235 236 236 ABSOLUTE_URL_OVERRIDES = {} 237 237 238 RELATED_NAME_OVERRIDES = {} 239 238 240 # Tuple of strings representing allowed prefixes for the {% ssi %} tag. 239 241 # Example: ('/home/html', '/var/www') 240 242 ALLOWED_INCLUDE_ROOTS = ()