def render(self, name, value, *args, attrs=None): if self.rel is not None: key = self.rel.get_related_field().name obj = self.rel.to._default_manager.get(**{key: value}) related_url = '../../../%s/%s/%d/' % ( self.rel.to._meta.app_label, self.rel.to._meta.object_name.lower(), value) value = "<a href='%s'>%s</a>" % (related_url, escape(obj)) final_attrs = self.build_attrs({name: name}) return mark_safe("<div%s>%s</div>" % (flatatt(final_attrs), linebreaks(value)))
def render(self, name, value, attrs=None, renderer=None): if self.remote_field is not None: key = self.remote_field.get_related_field().name if hasattr(self.remote_field, 'related_model'): related_model = self.remote_field.related_model else: related_model = self.remote_field.model obj = related_model._default_manager.get(**{key: value}) related_url = '../../../%s/%s/%d/' % (related_model._meta.app_label, related_model._meta.object_name.lower(), value) value = format_html("<a href='%s'>%s</a>" % (related_url, escape(obj))) final_attrs = self.build_attrs({name: name}) return mark_safe("<div%s>%s</div>" % (flatatt(final_attrs), linebreaks(value)))
def render(self, name, value, attrs=None, renderer=None): if self.remote_field is not None: key = self.remote_field.get_related_field().name related_model = self.remote_field.model obj = related_model._default_manager.get(**{key: value}) related_url = reverse( 'admin:{app_label}_{object_name}_change'.format( app_label=related_model._meta.app_label, object_name=related_model._meta.object_name.lower()), args=(value, )) value = format_html("<a href='%s'>%s</a>" % (related_url, escape(obj))) final_attrs = self.build_attrs({name: name}) return mark_safe("<div%s>%s</div>" % (flatatt(final_attrs), linebreaks(value)))
def render(self, name, value, attrs=None, renderer=None): if self.rel is not None: key = self.rel.get_related_field().name if hasattr(self.rel, 'related_model'): related_model = self.rel.related_model else: related_model = self.rel.to obj = related_model._default_manager.get(**{key: value}) related_url = '../../../%s/%s/%d/' % ( related_model._meta.app_label, related_model._meta.object_name.lower(), value) value = "<a href='%s'>%s</a>" % (related_url, escape(obj)) final_attrs = self.build_attrs({name: name}) return mark_safe("<div%s>%s</div>" % ( flatatt(final_attrs), linebreaks(value)))