我想创建一个manage.py命令,该命令从查询集中获取对象并将其发布到我的Twitter上.我打算使用这里描述的卷曲方法.
但Twitter已禁用基本身份验证.我不想安装类似Tweepy的过度库,让人们使用oAuth对我的网站进行身份验证,我只是想发推文.在一个帐户上.
我的模型看起来像这样:
class MenuItem(models.Model):
name = models.CharField(max_length=500)
components = models.ManyToManyField(Component, through=MenuItemComponent)
class Component(models.Model):
name = models.CharField(max_length=500)
class MenuItemComponent(models.Model):
menuItem = models.ForeignKey('MenuItem')
component = models.ForeignKey(Component)
isReplaceable = models.BooleanField()
Run Code Online (Sandbox Code Playgroud)
我想做的是在给定的MenuItem中公开一个包含isReplaceable字段的组件列表(NOT MenuItemComponents).到目前为止,我有:
#views.py
class MenuItemComponentList(generics.ListAPIView):
"""
Displays components for given MenuItem
"""
model = MenuItemComponent
serializer_class = MenuItemComponentSerializer
def get_queryset(self):
itemId = self.kwargs['itemId']
return MenuItemComponent.objects.filter(menuItem__pk=itemId)
#serializers.py
class MenuItemComponentSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = MenuItemComponent
Run Code Online (Sandbox Code Playgroud)
其中公开了MenuItemComponents列表并强制客户端进行多次调用以检索所有组件.使用isReplaceable字段中的其他数据公开组件列表可以解决问题.
编辑
最后,我想得到一个列出组件元素的列表,但元素是用MenuItemComponent模型中的isReplaceable字段扩展的:
{
"count": 2,
"next": null,
"previous": null,
"results": [
{
"url": "http://localhost:8000/api/component/1/",
"name": "component 1",
"isReplaceable": true
}, …
Run Code Online (Sandbox Code Playgroud) 我有两张桌子,每张桌子都有自己的模型......
class FamilyMan
{
public int family_ID {get; set;}
public string name {get; set;}
public string fav_color {get; set;}
}
class BusinessMan
{
public int work_ID {get; set;}
public string name {get; set;}
public string fav_color {get; set;}
//unrelated data etc
public string job_title {get; set;}
}
Run Code Online (Sandbox Code Playgroud)
...我希望能够将所有FamilyMans匹配到匹配的BusinessMans基于name
和fav_color
.
我目前有类似的东西:
//fill lists from database
var family_list = dbContext.FamilyMen.ToList();
var busy_list = dbContext.BusinessMen.ToList();
//create empty dict for matching the two types
var matches = new Dict<FamilyMan, BusinessMan>();
foreach …
Run Code Online (Sandbox Code Playgroud) 我在Apple网站上发现:
还提供支持以唤醒先前未自动连接的配对附件.
这对我来说很有用,因为用户在启动应用程序之前不需要每次都进行配对.
我提到了EAAccessory Manager API,但似乎没有这样的调用.
任何人都可以提供有关此主题的更多参考资料,我该如何去做?
现在我关注文章http://www.cocos2d-x.org/wiki/Effects.链接的示例会产生错误.经过测试的cocos2d-x版本是cocos2d-x 3.2beta0.
我的代码:
auto bgimage = Sprite::create("top.png");
bgimage->setPosition(visibleSize / 2);
// create a Lens3D action
ActionInterval* lens = Lens3D::create(10, Size(32, 24), Vec2(100, 180), 150);
// create a Waved3D action
ActionInterval* waves = Waves3D::create(10, Size(15, 10), 18, 15);
// create a sequence an repeat it forever
bgimage->runAction(RepeatForever::create(Sequence::create(waves, lens, NULL)));
this->addChild(bgimage);
Run Code Online (Sandbox Code Playgroud)
结果日志:
Assert failed: GridActions can only used on NodeGrid
Assertion failed!
File: CCActionGrid.cpp
Line: 84
Run Code Online (Sandbox Code Playgroud)
我弄错了什么?即使我删除液体动作线,wave3d和lens3d也显示我同样的错误.
我正在运行一个我想在它完成后重新运行的命令,而无需导航回终端再次输入该命令。
我知道在 Ubuntu 中,我可以使用命令运行终端,如果我设置正确,它将永远循环,例如gnome-terminal -x $MY_COMMAND
.
鉴于我无法将 Powershell 标记为重新运行命令而不是关闭窗口,我如何无限期地重复命令?
我有很多用户的chrome扩展,我想更新它.我准备好了一切,但我需要测试更新,以确保当前用户不会丢失数据.有没有办法只向受信任的测试人员发布新版本?
但我还是看不到新版本."发布到测试人员帐户"按钮仅在未发布的扩展名上.
我发现自己经常在提交消息中重复我编辑过的函数的名称,并且在编写提交消息时对我刚刚更改的函数进行自动完成是很好的.
是否有可能让vim以某种方式搜索当前提交的文件并获取函数名称,或者更好的是,仅修改它们?
我正在使用gVim7.3和C#,如果这完全相关的话.
它们在网页上看起来都看起来很相似,但每个HTML的HTML都差别很大:
<input id="TEST" name="TEST" type="text" value="this one's filled in, but editor isn't">
<input class="text-box single-line" id="TEST" name="TEST" type="text" value="">
Run Code Online (Sandbox Code Playgroud)
该文档说Returns an HTML input element for each property in the object that is represented by the expression.
的Html.Editor
虽然Html.TextBox说Returns a text input element by using the specified HTML helper and the name of the form field.
这是否意味着您将模型的字符串名称传递给Html.Editor
它,然后它将为每个属性创建一个文本输入,而这Html.TextBox
只是一个愚蠢的文本输入,在幕后没有别的东西?
是否可以确定当前正在评估哪种情况?像这个示例代码:
const int one = 1;
const int two = 2;
int current_num = 1;
switch (current_num){
case one:
case two:
WriteLine(current_case) //outputs 'one'
break;
}
Run Code Online (Sandbox Code Playgroud)
我相信我会变得棘手和使用字典什么的来查找current_num
一旦我开始WriteLine
,但也可能有一个内置的方式来获得当前的情况目前正在评估的名称.
编辑:简答,这是不可能的.查看JonSkeet的答案,找出合理的替代方案.
c# ×3
python ×2
asp.net-mvc ×1
bluetooth ×1
c++ ×1
cocos2d-x ×1
django ×1
eaaccessory ×1
git ×1
git-commit ×1
ios ×1
linq ×1
oauth ×1
powershell ×1
testing ×1
twitter ×1
version ×1
vim ×1