我在下面有以下管理操作将数据导出到CSV文件,我很难弄清楚如何在queryset参数上排序:
import csv
from django.core.exceptions import PermissionDenied
from django.http import HttpResponse
def export_as_csv(modeladmin, request, queryset):
"""
Generic csv export admin action.
"""
if not request.user.is_staff:
raise PermissionDenied
opts = modeladmin.model._meta
response = HttpResponse(mimetype='text/csv')
response['Content-Disposition'] = 'attachment; filename=%s.csv' % unicode(opts).replace('.', '_')
writer = csv.writer(response)
field_names = [field.name for field in opts.fields]
# Write a first row with header information
writer.writerow(field_names)
# Write data rows
for obj in queryset:
writer.writerow([getattr(obj, field) for field in field_names])
return response
export_as_csv.short_description = "Export selected objects …Run Code Online (Sandbox Code Playgroud) 请考虑以下列表:
items = ['about-conference','conf']
Run Code Online (Sandbox Code Playgroud)
使用以下for循环对列表进行迭代打印"about-conference"和"conf"
for word in items:
if 'conf' in word:
print word
Run Code Online (Sandbox Code Playgroud)
如果if语句遇到完全匹配,即只打印"conf",我如何才能将if语句证明为真?
谢谢.
我在Domino Designer中运行Domino应用程序,当我尝试通过url登录时:
http://localhost/net/test118/test.nsf/loginform?openform
Run Code Online (Sandbox Code Playgroud)
然后单击确定,URL重定向到[http://localhost/names.nsf?登录],我收到501错误:
HTTP Web Server: Function Not Implemented Exception
Run Code Online (Sandbox Code Playgroud)
任何想法,我如何成功登录?
谢谢
是否可以在Designer 8.5中更改端口号和主机?
我有以下方法来计算宽度和高度相等的正方形中的象限除以四个三角形:
function getQuadtrant(x, y, width, height){
if(y < width/2 && x < width-y && x > y) {
alert('top triangle');
}
if(y > width/2 && x > width-y && x < y) {
alert('bottom triangle');
}
if(x < height/2 && x < width-y && x < y) {
alert('left triangle');
}
if(x > height/2 && x > width-y && x > y) {
alert('right triangle');
}
}
Run Code Online (Sandbox Code Playgroud)
但是,我有一个矩形,宽度为 249 像素,高度为 404 像素,如何获得象限?上面的代码在当前状态下会给出错误的输出,当我选择三角形的特定区域时,例如顶部三角形,它会警告“底部三角形”。