问题列表 - 第16806页

django模板中的url模板标记

我试图在django中使用url模板标签,但没有幸运,

我像这样定义了我的urls.py

urlpatterns = patterns('',
    url(r'^analyse/$',              views.home,  name="home"),
    url(r'^analyse/index.html',     views.index, name="index"),
    url(r'^analyse/setup.html',     views.setup, name="setup"),
    url(r'^analyse/show.html',      views.show,  name="show"),
    url(r'^analyse/generate.html',  views.generate, name="generate"),
Run Code Online (Sandbox Code Playgroud)

我在这个视图中定义了url模式

{% url 'show'%}
Run Code Online (Sandbox Code Playgroud)

然后我收到此错误消息

渲染时捕获异常:反向''show''参数'()'和关键字参数'{}'未找到.

原始回溯(最近一次调用最后一次):文件"/Library/Python/2.5/site-packages/django/template/debug.py",第71行,在render_node结果= node.render(context)文件"/ Library/Python /2.5/site-packages/django/template/defaulttags.py",第155行,在渲染中nodelist.append(node.render(context))文件"/Library/Python/2.5/site-packages/django/template/defaulttags .py",第382行,在渲染中引发NoReverseMatch:反向''show'',参数'()'和关键字参数'{}'未找到.

我想知道为什么django无法渲染?什么是在tempalte中定义它的正确方法?

django-templates django-urls

11
推荐指数
3
解决办法
3万
查看次数

如何监听多个IP地址?

如果我的服务器分配了多个IP地址,并且我想听一些(或全部)它们,我该怎么做呢?

我是否需要为每个IP地址创建一个新套接字并绑定它?我可以将多个IP地址绑定到一个套接字吗?IPAddress.Any会监听所有IP地址吗?MSDN库在这个问题上非常不清楚.

c# sockets networking

8
推荐指数
1
解决办法
3万
查看次数

WPF ToggleButton和DelegateCommand

有没有办法确定是否ToggleButton通过DelegateCommands 检查/取消检查?

TIA,迈克

下面的XAML代码.我正在使用ItemsControl并绑定到一个集合.我基本上想要一种方法来获得每个按钮点击时的切换状态.

<ScrollViewer VerticalScrollBarVisibility="Auto">
    <ItemsControl ItemsSource="{Binding Modifiers, Mode=TwoWay}">
        <ItemsControl.Template>
            <ControlTemplate>
                <ScrollViewer ScrollViewer.VerticalScrollBarVisibility="Auto">
                    <WrapPanel Margin="10" Width="{TemplateBinding Width}"
                               Height="{TemplateBinding Height}" 
                               FlowDirection="LeftToRight" IsItemsHost="true">
                    </WrapPanel>
                </ScrollViewer>
            </ControlTemplate>
        </ItemsControl.Template>
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <ToggleButton FontSize="18" Opacity="0.8"
                              Command="{Binding DataContext.ModifierToggleCommand, 
                                        RelativeSource={RelativeSource FindAncestor,
                                        AncestorType={x:Type Views:ModifiersView}}}" 
                              CommandParameter="{Binding}" Height="80" Width="200" Margin="5"
                              Content="{Binding Path=ModifierName}" />
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>
</ScrollViewer>
Run Code Online (Sandbox Code Playgroud)

wpf commandbinding delegatecommand togglebutton

4
推荐指数
1
解决办法
4302
查看次数

如何针对十六进制值测试字节?

我想测试从数据文件中读取的字节是否为0xEE,我该怎么办?我试过if (aChar == 0xEE)但似乎没有用.

c++ hex char

3
推荐指数
2
解决办法
3869
查看次数

在grails服务中使用g.render

我正在尝试在grails服务中使用g.render,但似乎默认情况下不向服务提供g.有没有办法让模板引擎在服务中呈现视图?我可能会以错误的方式解决这个问题.我想要的是将视图从部分模板呈现为字符串,并将结果字符串作为JSON响应的一部分发回,以便与AJAX更新一起使用.

有什么想法吗?

ajax grails json render

18
推荐指数
2
解决办法
9612
查看次数

将消息发送到Windows进程(而不是其主窗口)

我有一个应用程序,在后续启动时检测是否已经运行了同名的进程,如果是,则激活正在运行的应用程序窗口,然后退出.

问题是主窗口可能被隐藏(只有通知区域图标可见),因此没有窗口句柄.

在启动时,前一个实例的MainWindowHandle属性为0,所以我无法发送ShowWindowPostMessage.

有没有办法可以发送一条可以被正在运行的应用程序截获的消息,从而允许它显示其主窗口?

该应用程序是用C#编写的,我正在使用以下代码实现此目的.

[STAThread]
static void Main()
{
    bool createdNew = true;
    using (Mutex mutex = new Mutex(true, "MyMutexName", out createdNew))
    {
        if (createdNew)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
        }
        else
        {
            Process current = Process.GetCurrentProcess();
            foreach (Process process in Process.GetProcessesByName(current.ProcessName))
            {
                if (process.Id != current.Id)
                {
                    Interop.WINDOWINFO pwi = new Interop.WINDOWINFO();
                    IntPtr handle = process.MainWindowHandle;
                    var isVisible = Interop.GetWindowInfo(handle, ref pwi);
                    if (!isVisible)
                    {
                        MessageBox.Show(Constants.APP_NAME + " is already running, check …
Run Code Online (Sandbox Code Playgroud)

.net c# windows interop

9
推荐指数
2
解决办法
3万
查看次数

如何修改C程序以便gprof可以对其进行分析?

当我在我的C程序上运行gprof时,它表示我的程序没有累积时间,并显示所有函数调用的0时间.但它会计算函数调用.

如何修改我的程序,以便gprof能够计算运行所需的时间?

c linux profiler profiling gprof

4
推荐指数
1
解决办法
7414
查看次数

以交互方式/非交互方​​式运行时,Python 以不同方式导入模块

我的一个 Python 脚本以交互模式运行,但从命令行运行时失败。不同之处在于,当从命令行运行时,它从一个坏的 .egg 文件中导入模块,而当以交互方式运行时,它使用当前目录中我的固定(解压缩)版本。

我的问题有两个方面:a) 为什么 Python 从这些位置运行时加载模块的方式不同,以及 b) 我有哪些解决方法?

python interactive egg non-interactive

5
推荐指数
1
解决办法
1845
查看次数

使用$ _POST变量的PHP if语句似乎不起作用.为什么?

在一台PHP服务器上,我有两个文件.一个文件(名称为"first.php")包含以下代码:

<html>
<head>
<title>First Page</title>
</head>
<body>
Please enter your password and age:
<form action="pass.php" method="post">
Name: <input type="text" name="fname" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

另一个文件("pass.php")包含以下代码:

<html>
<head>
<title>Secon Page</title>
</head>
<body>
<?php
if ($fname=="Jack")
  echo "You are Jack!";
else
  echo "You are not Jack!";
?>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

据我了解,如果用户在第一页输入"Jack",则第二页应显示"You are Jack!" 线,但它不会发生.为什么会这样?

php variables post

1
推荐指数
1
解决办法
5737
查看次数

在Haskell中比较通配符是否相等..?

在Haskell中,有没有办法比较所有通配符是否具有相同的类型和值?例如,我想创建一个表现出以下行为的函数:

(1 M) (2 M) (3 M) -> True
(1 S) (2 S) (3 S) -> True
(1 S) (2 M) (3 S) -> False
Run Code Online (Sandbox Code Playgroud)

换句话说,第一个参数应该是1,2和3,第二个参数应该是全部S或全部M.

在这种情况下,我们可以编写如下函数:

matches (1 _ ) (2 _ ) (3 _ )
Run Code Online (Sandbox Code Playgroud)

但是,我们如何确定通配符是全部是S还是全部M?

syntax haskell

4
推荐指数
1
解决办法
226
查看次数