我有一个这样设置的用户模型。
class ExternalUserModel(models.Model):
email = models.EmailField()
# other fields
class MyUserModel(models.Model):
external_user = models.ForeignKey(ExternalUserModel)
# other fields
Run Code Online (Sandbox Code Playgroud)
我正在尝试从电子邮件列表中获取 MyUserModel 列表。
这是我要执行的查询:
MyUserModel.objects.filter(external_user__email__iexact__in=user_emails)
Run Code Online (Sandbox Code Playgroud)
但我收到这个错误:
Unsupported lookup 'iexact' for EmailField or join on the field not permitted.
我需要 iexact,因为电子邮件列表基于用户输入,可能与数据库中存储的大小写不匹配。
我应该如何进行这个查询?
我是Haskell的新手,我想创建一个将两个列表合并在一起的函数,然后将组合列表从最小到最大排序.这应该在命令行中完成而不使用模块.
这是我目前所拥有的,我无法使"sortList"功能工作,我也不知道如何将这3行合并为1个函数.
let combineList xs ys = xs++ys
let zs = combineList xs ys
let sortList (z:zs) = if (head zs) < z then (zs:z) else (z:(sortList zs))
Run Code Online (Sandbox Code Playgroud) 这是我的代码,看起来像这样的小模式.(不是我所知道的最有效的代码).现在,我想stars使用旋转animate.但我不确定如何在一个程序中使用display和animate组合.任何帮助,将不胜感激.谢谢.

import Graphics.Gloss
main = display (InWindow "Gloss" (700,700) (0,0))
black (picture 100)
picture :: Float -> Picture
picture 0 = text "Value cannot be 0"
picture number = scale 6.5 6.5 (color rose $ drawpicture number)
orangered, orangered2, orangered3 :: Color
orangered = makeColor 1.0 0.251 0.0 0.7
orangered2 = makeColor 1.0 0.251 0.0 0.5
orangered3 = makeColor 1.0 0.251 0.0 0.3
intervalsmall = [0,11.25,22.5,33.75,45,56.25,67.5,78.75]
intervalbig = [0,22.5,45,67.5,90,112.5,135,157.5,180,202.5,225,247.5,270,292.5,315,337.5]
xlist = [2,4..50] …Run Code Online (Sandbox Code Playgroud) 我有一个像这样结构的字典列表.
[
{
'id': 1,
'last_message': {
'sent_at': '2015-10-15T17:48:52.515Z',
'...' : '...'
},
'...' : '...',
},
{
'id': 2,
'last_message': {
'sent_at': '2015-10-15T17:45:52.515Z',
'...' : '...'
},
'...' : '...',
},
{
'id': 3,
'last_message': {
'sent_at': '2015-10-15T17:43:52.515Z',
'...' : '...'
},
'...' : '...',
}
]
Run Code Online (Sandbox Code Playgroud)
并希望按列表排序['last_message']['sent_at'].
我尝试像这样进行插入排序,但这导致无限循环.
ret = []
for conversation in conversations:
if len(ret) > 1:
for conv in ret:
if conversation['last_message']['sent_at'] > conv['last_message']['sent_at']:
ret.insert(ret.index(conv), conversation)
continue
else:
ret.append(conversation)
Run Code Online (Sandbox Code Playgroud)
我能做些什么来实现这个目标?
我似乎无法获得有关haskell的光泽.我已经通过"cabal install gloss"安装了gloss-1.8.0.1.这是我的circle.hs文件.
import Graphics.Gloss
main = display (InWindow "Nice Window" (200, 200) (10, 10)) white (Circle 80)
Run Code Online (Sandbox Code Playgroud)
从我的理解,当我通过ghci打开这个文件.将弹出一个名为"Nice Window"的窗口,它将为我精心绘制我的圆圈.
但是,当我打开它.这是输出.
[1 of 1] Compiling Main C:\Users\... Path here, interpreted
Ok, modules loaded: Main.
*Main>
Run Code Online (Sandbox Code Playgroud)
即使我试图直接在ghci画画
import Graphics.Gloss
picture = circle 80
Run Code Online (Sandbox Code Playgroud)
会回来的
<interactive>:3:9 parse error on input '='
Run Code Online (Sandbox Code Playgroud)