走过海棠暮

文章 0 评论 0 浏览 24

走过海棠暮 2024-11-25 21:38:47

您不能像模板中那样对变量建立索引。我建议以另一种方式进行:

for choice in choices:
   ...
  choice.percentage = vote_percentage

...

{% for choice in poll.choice_set.all %}
    <li>{{ choice.choice }} - {{ choice.percentage }} ({{ choice.votes }}) </li>
{% endfor %}

You can't index dictionaries on a variable like that in templates. I recommend doing it the other way:

for choice in choices:
   ...
  choice.percentage = vote_percentage

...

{% for choice in poll.choice_set.all %}
    <li>{{ choice.choice }} - {{ choice.percentage }} ({{ choice.votes }}) </li>
{% endfor %}

Django 模板未正确显示

走过海棠暮 2024-11-25 20:18:17

我会推荐一些并发集合,您DataBind 到您的 ListView 控件。在整个应用程序中传递对表单的引用并不是一个好主意。

我的建议是使用 ConcurrentBagObservableCollection

I would recommend some concurrent collection to which you DataBind to your ListView control. It is not a good idea to be passing around references to your form throughout the application.

My recommendation would be to use either the ConcurrentBag<T> or ObservableCollection<T>.

从静态方法访问成员变量?

走过海棠暮 2024-11-25 17:40:52

当浏览器从头到尾解析 HTML 文件并将其转换为 DOM 结构时,将触发文档的就绪事件。它不以任何方式保证任何其他资源(例如样式表、图像或本例中的脚本)将会加载。它仅引用 DOM 结构,并且无论页面资源的加载状态如何都会被触发。

如果您想等待资源加载,请使用 windowload 事件,该事件仅在页面上的每个元素完成加载时触发。

请参阅:

The document's ready event is fired when the browser has parsed the HTML file from beginning to end and converted it into a DOM structure. It does not in any way guarantee that any other resources (e.g. stylesheets, images or, as in this case, scripts) will have loaded. It only refers to the DOM structure, and is fired irrespective of the loading status of the page's resources.

If you want to wait for resources to load, use the window's load event, which is fired only when every element on the page has finished loading.

See:

$(document).ready 到底保证了什么?

走过海棠暮 2024-11-25 07:04:46

我正在研究这个问题,但 Google+ 没有获取我的 OG 标签。

当我将 放入 HTML 中时,它开始拾取它们。

希望这可以节省一些人的时间!

I am working on this, and Google+ wasn't picking up my OG tags.

When I put: <body itemscope itemtype="http://schema.org/Article"> into the HTML it started to pick them up.

Hope this saves someone some time!

是否有标签可以指定 Google+1 中的 Google+1 故事格式?就像 Facebook 的 og-meta 一样?

走过海棠暮 2024-11-25 06:08:09

我使用 Telerik mvc 网格作为主网格,它支持分组、排序、分页和大多数花哨的东西。他们的网站上也有工作示例。

I have used Telerik mvc grid as a master grid, and it does support grouping, sorting, paging and most of the fancy stuff. They also have working samples on their site.

MVC 贡献网格

走过海棠暮 2024-11-25 06:05:33

一种解决方案是使用资源文件。通过右键单击项目并选择项目属性来添加资源。然后单击资源并添加新资源。

我们从问题中的例子开始工作:
对于资源,我们不能遵循如上所示的相同命名约定。我们需要替换“.”带“_”即: success.message ->成功消息
资源文件不允许使用“.”在键名称中。

接下来我们需要将消息写入资源文件中。
“{0}已成功提交文件。”
我们使用 {0}....{x} 作为变量的占位符。

资源选项卡中的第一行应如下所示

success_message | {0} successfully submitted the file.

替换占位符的函数应如下所示:

Public Shared Function messageRetriver(ByVal message As String, ByVal variables As String()) As String
    Dim i As Integer
    Dim pattern As String
    For i = 0 To variables.Length - 1
        pattern = "\x7B" & i & "\x7D"
        Dim myRegex As New Regex(pattern)
        message = myRegex.Replace(message, variables(i))
    Next
    Return message
End Function

现在,在代码中,您所要做的就是调用此函数并传递资源和变量的字符串数组。

Utility.messageRetriver(My.Resources.success_message, {"My Program"})

那应该可以解决问题。
我使用作为编译此信息的资源。

One solution is to use resource files. Add a resource by right clicking on the project and selecting project properties. Then click on resources, and add a new resource.

We work from the example in the question :
With resources we cannot follow the sam naming convention as you see above. We need to replace the '.' with a '_' ie: success.message -> success_message
Resource files do not allow the '.' in the key name.

Next we need to the message into the resource file.
"{0} successfully submitted the file."
We use {0}....{x} as place holders for variables.

The first line in the resource tab should look like this

success_message | {0} successfully submitted the file.

The function to do the replacing of the place holders should look like this:

Public Shared Function messageRetriver(ByVal message As String, ByVal variables As String()) As String
    Dim i As Integer
    Dim pattern As String
    For i = 0 To variables.Length - 1
        pattern = "\x7B" & i & "\x7D"
        Dim myRegex As New Regex(pattern)
        message = myRegex.Replace(message, variables(i))
    Next
    Return message
End Function

Now in your code all you have to do is call this function passing the resource, and the string array of variables.

Utility.messageRetriver(My.Resources.success_message, {"My Program"})

That should do the trick.
I used this as a resource to compile this information.

消息属性文件

走过海棠暮 2024-11-25 05:24:37

尝试使用积极维护的 CouchDB 库 http://www.ektorp.org/

Try a CouchDB lib that is actively maintained http://www.ektorp.org/ instead.

如何使用 couchdb4j api 使用用户名和密码连接到 couchdb 数据库?

走过海棠暮 2024-11-25 04:09:23

MAC_OS_X_VERSION_MAX_ALLOWED 设置为 1050 并查看哪些符号消失。更多信息请参见 TN2064

Set MAC_OS_X_VERSION_MAX_ALLOWED to 1050 and see what symbols disappear. More info in TN2064.

使用 xcode 4 但针对 OSX Leopard (10.5) 及更高版本

走过海棠暮 2024-11-25 03:11:59

当您获取当时仅声明的类的sizeof时,就会导致此错误。例如class MyClass; const size_t error = sizeof(MyClass);

请注意,稍后是否完全定义该类并不重要:定义必须位于 sizeof 之前。

This error is caused when you take the sizeof of a class that's only declared at that point. E.g. class MyClass; const size_t error = sizeof(MyClass);.

Note that it doesn't matter whether the class is fully defined later: the definition must precede the sizeof.

关于 C++ 中 sizeof(class) 使用引发的错误

走过海棠暮 2024-11-24 23:03:09

a 是一个指针。您需要使用->,而不是

a is a pointer. You need to use->, not .

表达式必须具有类类型

走过海棠暮 2024-11-24 21:29:05

您需要在枚举中声明抽象方法,然后在特定的枚举实例中实现这些方法。

class Outer {

    private enum MyEnum {
        X {
            public void calc(Outer o) {
                // do something
            }
        },
        Y {
            public void calc(Outer o) {
                // do something different
                // this code not necessarily the same as X above
            }
        },
        Z {
            public void calc(Outer o) {
                // do something again different
                // this code not necessarily the same as X or Y above
            }
        };

        // abstract method
        abstract void calc(Outer o);
    }

    public void doCalc() {
        for (MyEnum item : MyEnum.values()) {
            item.calc(this);
        }
    }
}

You need to declare abstract methods in your enum which are then implemented in specific enum instances.

class Outer {

    private enum MyEnum {
        X {
            public void calc(Outer o) {
                // do something
            }
        },
        Y {
            public void calc(Outer o) {
                // do something different
                // this code not necessarily the same as X above
            }
        },
        Z {
            public void calc(Outer o) {
                // do something again different
                // this code not necessarily the same as X or Y above
            }
        };

        // abstract method
        abstract void calc(Outer o);
    }

    public void doCalc() {
        for (MyEnum item : MyEnum.values()) {
            item.calc(this);
        }
    }
}

枚举:每个实例独有的方法

走过海棠暮 2024-11-24 20:44:23

通常这是通过服务控制操作来完成的。基本上,您需要设置停止和删除标志才能卸载。

另一种方法是使用 ServiceInstaller.Uninstall 在自定义操作中停止并删除服务。

如果您想避免出现文件正在使用对话框,您可以尝试以下方法:
从安装程序类停止 Windows 服务时出现问题。事件触发得太晚了

Usually this is done through service control operations. Basically, you need the Stop and Delete flags set for uninstall.

Another approach would be to use ServiceInstaller.Uninstall in a custom action to stop and remove the service.

If you want to avoid the files in use dialog, you can try this approach:
Problem stopping Windows Service from Installer Class. Events fire too late

安装前停止服务

走过海棠暮 2024-11-24 18:49:47

示例:

[fname,fpath] = uigetfile({'*.xls';'*.xlsx'});
if fpath==0, error('no file selected'); end

[num,txt,raw] = xlsread( fullfile(fpath,fname) );

该文件可以位于硬盘上的任何位置...

Example:

[fname,fpath] = uigetfile({'*.xls';'*.xlsx'});
if fpath==0, error('no file selected'); end

[num,txt,raw] = xlsread( fullfile(fpath,fname) );

The file can be located anywhere on your hard-disk...

xlsread 找不到现有文件 - matlab

走过海棠暮 2024-11-24 18:30:56

因此,该错误似乎与 Norton File Insight 相关。它无法检查 MSI 文件中的数字证书。您可以在 Symantec 论坛中阅读相关信息:http://community.norton.com/t5/Norton-Internet-Security-Norton/Bug-with-File-Insight-not-detecting-digital-signature/mp/491390/highlight/false# M164254。一名工作人员最终承认这个问题将在 2012 年得到解决。

但是,来吧,检测数字证书并不困难,而且这是检查恶意软件的基本部分。恶意软件很少经过数字签名,在极少数情况下,它永远不会使用来自受信任机构的证书进行数字签名,除非它已被泄露。 IE9 认识到这些事实并采取相应的行动。

赛门铁克已经注意到这个错误至少两年了,而且它一定很容易修复。但问题仍然存在。

So, it seems that the bug is with Norton File Insight. It's unable to check MSI files for digital certificates. You can read about in the Symantec forum here: http://community.norton.com/t5/Norton-Internet-Security-Norton/Bug-with-File-Insight-not-detecting-digital-signature/m-p/491390/highlight/false#M164254. One of the staff members finally admitted that this is an issue that will be fixed in 2012.

But, come on, detecting a digital certificate is not exactly difficult and it's such a basic part of checking for malware. Malware is rarely digitally signed and in the rare case it's signed, it is never digitally signed with a certificate from a trusted authority unless it has been compromised. IE9 recognizes these facts and acts accordingly.

Symantec has had notice of this bug for at least two years and it must be easy to patch. But the problem continues.

有没有办法对 MSI 文件进行签名以便 Norton Internet Security 识别它?

走过海棠暮 2024-11-24 17:27:39

执行相同的操作,但用逗号分隔地址的每个部分。

http://maps.google.com/maps?saddr=47.295601,0.010586
&daddr=123 Main Street, Houston, Texas, 77707
+t‌​o:47.295601,2.010586
+to:321 Avenue A, Baton Rouge, Lousiana, 68594
+to:42.223501,2.011586
+to:35.215621,1.020456

您可以使用坐标和地址的组合。

Do the same thing but separate each part of the address with commas.

http://maps.google.com/maps?saddr=47.295601,0.010586
&daddr=123 Main Street, Houston, Texas, 77707
+t‌​o:47.295601,2.010586
+to:321 Avenue A, Baton Rouge, Lousiana, 68594
+to:42.223501,2.011586
+to:35.215621,1.020456

You may use a combination of coordinates and addresses.

谷歌地图查询地址字符串格式而不是纬度/经度?

更多

推荐作者

浪漫人生路

文章 0 评论 0

620vip

文章 0 评论 0

羞稚

文章 0 评论 0

走过海棠暮

文章 0 评论 0

你好刘可爱

文章 0 评论 0

陌若浮生

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文