💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
>[success] # 增加一个有情链接 ![](https://box.kancloud.cn/f48f326f82d39c11864bf21eb94dd2cf_1033x223.png) >[danger] ##### 配置url ~~~ url(r'^links/$', LinkView.as_view(), name="links"), ~~~ >[danger] ##### 在config 模块下编写views ~~~ queryset 可以直接编写 这个属性来规定返回的查询值 ~~~ ~~~ from django.shortcuts import render from django.views.generic import ListView from .models import Link from blong.views import CommonMixin # Create your views here. class LinkView(CommonMixin, ListView): queryset = Link.objects.filter(status=1) # 注释这里 template_name = 'config/links.html' context_object_name = 'links' # 在页面显示的变量 context 默认是 object_list ~~~ >[danger] ##### 在templates /config 文件下编写link.html ~~~ 1./favicon.ico网站图片 ~~~ ~~~ {% extends "blog/base.html" %} {% block content %} <table class="table"> <thead> <tr> <th scope="col">#</th> <th scope="col">名称</th> <th scope="col">网址</th> </tr> </thead> <tbody> {% for link in links %} <tr> <th scope="row">{{ forloop.counter }}</th> <td>{{ link.title }}</td> <td><a href="{{ link.href }}" target="_blank"><img height="20px" src="{{ link.href }}/favicon.ico"></a></td> </tr> {% endfor %} </tbody> </table> {% endblock %} ~~~