Django:找到带有值的id

2024-09-30 06:28:44 发布

您现在位置:Python中文网/ 问答频道 /正文

如何找到值列表的id

以下是我所拥有的:

你知道吗视图.py地址:

        group = Groups_By_Dates.objects.filter(date=date)

        all_groups = group.values_list('time', flat=True)

        time = Groups_By_Dates.objects.get(time=???)

我需要能够找到时间,以便我可以使用它在我的模板为一个网址以后。我怎么能做到呢?你知道吗

我已经试过了,但没用:

{% for grouptime in all_groups %}
    <div class="row1">
        <a href='{% url "listbygroup" time.id %}'> {{grouptime}}</a>
    </div>
    <div class="row2">

    </div>
{% endfor %} 

Tags: div视图id列表datebyobjectstime
1条回答
网友
1楼 · 发布于 2024-09-30 06:28:44

试试这个

times = Groups_By_Dates.objects.filter(time_id__in=Groups_By_Dates.objects.filter(date=date).values('time'))
time = times.first()

相关问题 更多 >

    热门问题