(field_name)
return _linkify
Converts a foreign key value into clickable links.

    If field_name is 'parent', link text will be str(obj.parent)
    Link will be admin url for the admin url for obj.parent.id:change
Converts a foreign key value into clickable links.
Converts a foreign key value into clickable links .
def foreignkey(field_name):
    """
    Converts a foreign key value into clickable links.

    If field_name is 'parent', link text will be str(obj.parent)
    Link will be admin url for the admin url for obj.parent.id:change
    """
    @mark_safe
    def _linkify(obj):
        app_label = obj._meta.app_label
        linked_obj = getattr(obj, field_name)
        model_name = linked_obj._meta.model_name
        view_name = "admin:{app_label}_{model_name}_change".format(
            app_label=app_label,
            model_name=model_name
        )
        link_url = reverse(view_name, kwargs=dict(
            object_id=linked_obj.id,
            wechat_app_id=obj.app_id
        ))
        return '<a href="{0}">{1}</a>'.format(link_url, linked_obj)

    _linkify.short_description = _(field_name)
    _linkify.admin_order_field = field_name
    return _linkify
def foreignkey ( field_name ) : @ mark_safe def _linkify ( obj ) : app_label = obj . _meta . app_label linked_obj = getattr ( obj , field_name ) model_name = linked_obj . _meta . model_name view_name = "admin:{app_label}_{model_name}_change" . format ( app_label = app_label , model_name = model_name ) link_url = reverse ( view_name , kwargs = dict ( object_id = linked_obj . id , wechat_app_id = obj . app_id ) ) return '<a href="{0}">{1}</a>' . format ( link_url , linked_obj ) _linkify . short_description = _ ( field_name ) _linkify . admin_order_field = field_name return _linkify