查看“Python Web开发:通知公告”的源代码
←
Python Web开发:通知公告
跳转至:
导航
,
搜索
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
==实训步骤== ===修改视图函数=== homeApp/views.py: <nowiki> def home(request): ... # 通知公告 noteList = MyNew.objects.all().filter( Q(newType='通知公告')).order_by('-publishDate') if (len(noteList) > 4): noteList = noteList[0:4] ... # 返回结果 return render(request, 'home.html', { 'active_menu': 'home', 'postList': postList, 'newList': newList, 'noteList': noteList, })</nowiki> ===编辑前端页面=== <nowiki> <!-- 通知公告 --> <span class="part1"> <a href="#">通知公告</a> </span> <span class="part1 en"> / Public Release </span> <a class="btn btn-default btn-xs more-btn" href="{% url 'newsApp:news' 'notice' %}"> + 更多 </a> <div class="line1"> <div class="line2 theme"></div> </div> <div> <img class="img-responsive" src="{% static 'img/note.jpg' %}"> <ul class="list-unstyled list-new"> {% for note in noteList %} <li> <a href="{% url 'newsApp:newDetail' note.id %}"> {{note.title|truncatechars:"25"}} </a> <a href="{% url 'newsApp:newDetail' note.id %}" class="public-detail"> 查看详情>> </a> </li> {% endfor %} </ul> </div></nowiki> ==效果== [[文件:python21060801.png|300px]]
返回至
Python Web开发:通知公告
。
导航菜单
个人工具
登录
命名空间
页面
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
导航
首页
最近更改
随机页面
帮助
工具
链入页面
相关更改
特殊页面
页面信息