我有一个简单的应用程序,用户应该在比赛结果上下注.比赛由两个队组成,一个结果和一个赌注.在Django管理员中创建与团队的匹配,参与者将填写结果和赌注.
必须根据数据库中的匹配动态生成表单.
我的想法是为每个匹配设置一个(Django)Form实例,并将这些实例传递给模板.
当我从django shell执行它时,它工作正常,但是当我加载视图时,实例不会呈现.
表单如下所示:
class SuggestionForm(forms.Form):
def __init__(self, *args, **kwargs):
try:
match = kwargs.pop('match')
except KeyError:
pass
super(SuggestionForm, self).__init__(*args, **kwargs)
label = match
self.fields['result'] = forms.ChoiceField(label=label, required=True, choices=CHOICES, widget=forms.RadioSelect())
self.fields['stake'] = forms.IntegerField(label='', required=True, max_value=50, min_value=10, initial=10)
Run Code Online (Sandbox Code Playgroud)
我的(初步)视图如下所示:
def suggestion_form(request):
matches = Match.objects.all()
form_collection = {}
for match in matches:
f = SuggestionForm(request.POST or None, match=match)
form_collection['match_%s' % match.id] = f
return render_to_response('app/suggestion_form.html', {
'forms': form_collection,
},
context_instance = RequestContext(request)
)
Run Code Online (Sandbox Code Playgroud)
我最初的想法是,我可以将form_collection传递给模板,并将循环传递给像这样的集合,但是id不起作用:
{% for form in forms %}
{% …Run Code Online (Sandbox Code Playgroud) 我试图理解从C#代码实现COM接口的正确原因是什么.当接口不从其他基接口继承时,它很简单.像这个:
[ComImport, Guid("2047E320-F2A9-11CE-AE65-08002B2E1262"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IShellFolderViewCB
{
long MessageSFVCB(uint uMsg, int wParam, int lParam);
}
Run Code Online (Sandbox Code Playgroud)
然而,当我需要实现从其他COM接口继承的接口时,事情开始变得疲惫不堪.例如,如果我实现IPersistFolder2继承的接口,就像我通常在C#代码上IPersistFolder继承的IPersist那样:
[ComImport, Guid("0000010c-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IPersist
{
void GetClassID([Out] out Guid classID);
}
[ComImport, Guid("000214EA-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IPersistFolder : IPersist
{
void Initialize([In] IntPtr pidl);
}
[ComImport, Guid("1AC3D9F0-175C-11d1-95BE-00609797EA4F"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IPersistFolder2 : IPersistFolder
{
void GetCurFolder([Out] out IntPtr ppidl);
}
Run Code Online (Sandbox Code Playgroud)
操作系统无法调用我的对象实现上的方法.当我调试时,我可以看到我的IPersistFolder2实现的构造函数被多次调用,但是我实现的接口方法没有被调用.我正在实施IPersistFolder2如下:
[Guid("A4603CDB-EC86-4E40-80FE-25D5F5FA467D")]
public class PersistFolder: IPersistFolder2
{
void IPersistFolder2.GetClassID(ref Guid classID) …Run Code Online (Sandbox Code Playgroud) 我需要一个用于C#语法高亮的Eclipse 3插件,并希望代码完成.
我正在运行Mac和Windows版本的Eclipse.
我已经评估过"改进C#",但似乎没有用.
c# eclipse eclipse-plugin syntax-highlighting code-completion
而不是为每个字母制作宏,如
\def\bA{\mathbf{A}}
...
\def\bZ{\mathbf{Z}}
Run Code Online (Sandbox Code Playgroud)
有没有办法循环一个字符类(如大写字母)并为每个字符生成宏?我也想对希腊字母做同样的事情(使用bm而不是mathbf).
我上课了RoomType:
Int32 Id
String Name
String ColorCode
Run Code Online (Sandbox Code Playgroud)
我的viewmodel得到一个List<Roomtype> RoomTypes应该在下拉列表中显示的内容.
每个下拉选项都应该具有:1)作为标题Name,2)作为值Id,以及3)样式背景颜色#ColorCode.
我的问题是如何正确地将此列表转换List<SelectListItem>为ASP.NET MVC的DropDownFor帮助程序所需的,然后为每个选项插入正确的值.
我试图在我的viewmodel中有一个新的readonly属性,它有一个RoomtypeSelectList返回的getter ,new SelectList(RoomTypeList)但是我无法显示正确的属性(Name,Id,Background color).
我很欣赏一些正确方向的帮助或指示......
让我们建议我在Spring中定义一个bean:
<bean id="neatBean" class="com..." abstract="true">...</bean>
Run Code Online (Sandbox Code Playgroud)
然后我们有许多客户端,每个客户端的'neatBean'配置略有不同.我们这样做的旧方法是为每个客户端(例如,clientX_NeatFeature.xml)创建一个新文件,其中包含一堆用于此客户端的bean(这些是手工编辑的,代码库的一部分):
<bean id="clientXNeatBean" parent="neatBean">
<property id="whatever" value="something"/>
</bean>
Run Code Online (Sandbox Code Playgroud)
现在,我希望有一个UI,我们可以动态编辑和重新定义客户端的neatBean.
我的问题是:给定一个neatBean,以及一个可以"覆盖"该bean属性的UI,将这个序列化为XML文件的简单方法就像我们今天[手动]一样?
例如,如果用户为客户端Y设置属性为"17",我想要生成:
<bean id="clientYNeatBean" parent="neatBean">
<property id="whatever" value="17"/>
</bean>
Run Code Online (Sandbox Code Playgroud)
请注意,将此配置移动到其他格式(例如,数据库,其他架构-xml)是一种选择,但不是对手头问题的真正答案.
是否有一种简单的方法(在VIM中)使用当前名称加上附加短语保存当前打开的文件?
IE,来自/home/affert/类型vim /data/folder/file1.txt
然后保存文件,/data/folder/file1.txt_BACKUP而无需复制和粘贴文件名?
上下文:我有一个文件,其中包含其他文件夹中其他文件的完整路径.我用来ctrl+W, ctrl+F在新窗口中打开文件.这就是为什么我不想复制和粘贴.顺便说一下,文件夹和文件名要长很多,所以自己键入它们并不是一个有用的选项.
我在Google Analytics中设置了一些目标,可以使用一些正则表达式帮助.
假设我有4个网址
http://www.anydotcom.com/test/search.cfm?metric=blah&selector=size&value=1
http://www.anydotcom.com/test/search.cfm?metric=blah2&selector=style&value=1
http://www.anydotcom.com/test/search.cfm?metric=blah3&selector=size&value=1
http://www.anydotcom.com/test/details.cfm?metric=blah&selector=size&value=1
Run Code Online (Sandbox Code Playgroud)
我想创建一个表达式,它将标识包含字符串selector = size但不包含details.cfm的任何URL
我知道要找到一个不包含其他字符串的字符串,我可以使用这个表达式:
(^((?!details.cfm).)*$)
Run Code Online (Sandbox Code Playgroud)
但是,我不确定如何添加selector = size部分.
任何帮助将不胜感激!
我正在写一个充当媒体播放器的iPad应用程序(视频和照片).我知道应用程序有2GB的大小限制,但这是下载时应用程序的大小限制吗?或者在应用程序的整个生命周期中限制沙盒的大小?例如,如果我的小应用程序稍后将各种媒体文件下载到其沙盒中,使用户总数超过2GB(应用程序+下载的媒体),该怎么办?
谢谢!