Django模块模板渲染之django.shortcuts包含的函数及使用
来源:互联网 发布:淘宝模特红人有哪些 编辑:程序博客网 时间:2024/06/15 04:23
django shortcuts渲染模板模块
这里没有单独的使用介绍,只有这个模块下包含的这些函数的介绍,自己记录也欢迎大家浏览
from django.shortcuts import render_to_response
def render_to_response(template_name, context=None, context_instance=_context_instance_undefined, content_type=None, status=None, dirs=_dirs_undefined, dictionary=_dictionary_undefined, using=None): """返回其内容被调用结果填充的HttpResponsedjango.template.loader.render_to_string()与传递的参数。 """
from django.shortcuts import render
def render(request, template_name, context=None, context_instance=_context_instance_undefined, content_type=None, status=None, current_app=_current_app_undefined, dirs=_dirs_undefined, dictionary=_dictionary_undefined, using=None):
"""返回其内容被调用结果填充的HttpResponsedjango.template.loader.render_to_string()与传递的参数。默认情况下使用请求上下文。"""
from django.shortcuts import redirect
def redirect(to, *args, **kwargs):
"""
返回一个HttpResponseRedirect通过参数到相应URL参数可以是:*模型:模型的get_absolute_url()函数将被调用。*视图名称,可能带有参数:urlresolvers.reverse()将用于反向解析名称。*一个URL,它将被用于重定向位置。默认情况下,临时重定向;permanent=True 来发布永久重定向
"""
from django.shortcuts import _get_queryset
def _get_queryset(klass):
”“”从模型、管理器或QuerySet中返回一个QuerySet。为了使get_object_or_404和get_list_or_404更加DRY(代码不重复)。如果klass不是Modle、Manager或QuerySet,那么就会产生一个ValueError。”“”
from django.shortcuts import get_object_or_404
def get_object_or_404(klass, *args, **kwargs):
“”“使用get()返回一个对象如果对象不存在返回Http404异常。klass可能是一个Model、Manager或QuerySet对象。get()查询中使用了参数和关键字参数。注意:就像get()一样,如果有多个返回对象,则返回多个对象。”“”
from django.shortcuts import get_list_or_404
def get_list_or_404(klass, *args, **kwargs):
"""
使用filter()返回一个对象列表,如果列表为空则返回一个Http404异常
klass可能是一个Model、Manager或QuerySet对象。
filter()查询中使用了参数和关键字参数。
"""
from django.shortcuts import resolve_url
def resolve_url(to, *args, **kwargs):
"""
返回一个与所传递参数相对应的URL。参数可以是:*模型:模型的get_absolute_url()函数将被调用。*视图名称,可能带有参数:' urlresolvers.reverse()将用于反向解析名称。*一个URL,它将按原样返回。
"""
阅读全文
0 0
- Django模块模板渲染之django.shortcuts包含的函数及使用
- Django 之 模板继承 及 函数应用
- [Django模板系统]Django的模板渲染(render)机制
- Django模板渲染
- Django模板的使用
- Django模板的使用
- django模板的使用
- Django-模板的使用
- Django的render(模板渲染)机制
- 第二章:Django模板的渲染
- django学习04---模板的渲染
- python django模板的使用
- Django笔记---模板的使用
- django-模板标签的使用
- [django]入门教程3:模板语法及使用
- django模板 过滤函数
- 啦啦啦啦~Django1.96---Django的模板渲染(render)机制
- Python日记——Django模板的渲染
- spring中的scope详解
- 谈谈吧,谈谈现在谈谈过去谈谈未来
- redis基础知识
- Python图像处理库PIL中图像格式转换
- hdoj 1141 Factstone Benchmark(数学题。。)
- Django模块模板渲染之django.shortcuts包含的函数及使用
- Xshell5 评估过期,需要采购,不能使用
- windbg 如何在内核模式调试用户空间的程序
- Yii2连接oracle中文乱码解决方法之一
- abstract class和interface的区别
- 如何通过各种数据挖掘运维价值
- 网络流24题一句话题解集合
- mongodb笔记03(MongoDB 条件操作符)
- leetcode 600 Count number of binary strings without consecutive 1