<commit_before>from django.core import paginator
from django.template.response import TemplateResponse


__all__ = ("template_name", "render_list", "render_detail")


def template_name(model, template_name_suffix):
    """
    Given a model and a template name suffix, return the resulting template
    path::

        >>> template_name(Article, "_detail")
        "articles/article_detail.html"
        >>> template_name(User, "_form")
        "auth/user_form.html"
    """

    return "%s/%s%s.html" % (
        model._meta.app_label,
        model._meta.model_name,
        template_name_suffix,
    )


def render_list(
    request,
    queryset,
    context=None,
    *,
    model=None,
    paginate_by=None,
    template_name_suffix="_list",
):
    """
    Render a list of items

    Usage example::

        def article_list(request, ...):
            queryset = Article.objects.published()
            return render_list(
                request,
                queryset,
                paginate_by=10,
            )

    You can also pass an additional context dictionary and/or specify the
    template name suffix. The query parameter ``page`` is hardcoded for
    specifying the current page if using pagination.

    The queryset (or the page if using pagination) are passed into the template
    as ``object_list`` AND ``<model_name>_list``, i.e. ``article_list`` in the<commit_msg>Fix a possible syntax error<commit_after>from django.core import paginator
from django.template.response import TemplateResponse


__all__ = ("template_name", "render_list", "render_detail")


def template_name(model, template_name_suffix):
    """
    Given a model and a template name suffix, return the resulting template
    path::

        >>> template_name(Article, "_detail")
        "articles/article_detail.html"
        >>> template_name(User, "_form")
        "auth/user_form.html"
    """

    return "%s/%s%s.html" % (
        model._meta.app_label,
        model._meta.model_name,
        template_name_suffix,
    )


def render_list(
    request,
    queryset,
    context=None,
    *,
    model=None,
    paginate_by=None,
    template_name_suffix="_list"
):
    """
    Render a list of items

    Usage example::

        def article_list(request, ...):
            queryset = Article.objects.published()
            return render_list(
                request,
                queryset,
                paginate_by=10,
            )

    You can also pass an additional context dictionary and/or specify the
    template name suffix. The query parameter ``page`` is hardcoded for
    specifying the current page if using pagination.

    The queryset (or the page if using pagination) are passed into the template
    as ``object_list`` AND ``<model_name>_list``, i.e. ``article_list`` in the
{'fraction_non_alphanumeric': 0.09711846318036287, 'fraction_numerical': 0.001422981145499822, 'mean_word_length': 2.5640050697084917, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '75968', 'n_tokens_mistral': 817, 'n_tokens_neox': 776, 'n_words': 227}