<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">from django.db import models

from .base import library
from .linkcolumn import BaseLinkColumn


@library.register
class URLColumn(BaseLinkColumn):
    """
    Renders URL values as hyperlinks.

    Arguments:
        text (str or callable): Either static text, or a callable. If set, this
            will be used to render the text inside link instead of value (default)
        attrs (dict): Additional attributes for the ``&lt;a&gt;`` tag

    Example::

        &gt;&gt;&gt; class CompaniesTable(tables.Table):
        ...     link = tables.URLColumn()
        ...
        &gt;&gt;&gt; table = CompaniesTable([{"link": "http://google.com"}])
        &gt;&gt;&gt; table.rows[0].get_cell("link")
        '&lt;a href="http://google.com"&gt;http://google.com&lt;/a&gt;'
    """

    def get_url(self, value):
        return value

    @classmethod
    def from_field(cls, field, **kwargs):
        if isinstance(field, models.URLField):
            return cls(**kwargs)
</pre></body></html>