我想制作一个用于过滤搜索的表单,不需要任何字段.例如,给出此代码:
models.py:
class Message(models.Model):
happened = models.DateTimeField()
filename = models.CharField(max_length=512, blank=True, null=True)
message = models.TextField(blank=True, null=True)
dest = models.CharField(max_length=512, blank=True, null=True)
fromhost = models.ForeignKey(Hosts, related_name='to hosts', blank=True, null=True)
TYPE_CHOICES = ( (u'Info', u'Info'), (u'Error', u'Error'), (u'File', u'File'), (u'BPS', u'BPS'),)
type = models.CharField(max_length=7, choices=TYPE_CHOICES)
job = models.ForeignKey(Jobs)
Run Code Online (Sandbox Code Playgroud)
views.py:
WHEN_CHOICES = ( (u'', ''), (1, u'Today'), (2, u'Two days'), (3, u'Three Days'), (7, u'Week'),(31, u'Month'),)
class MessageSearch(ModelForm): #Class that makes a form from a model that can be customized by placing info …Run Code Online (Sandbox Code Playgroud) 我有以下json字符串(jsonString)
[
{
"name":"Fruits",
"references":[
{"stream":{"type":"reference","size":"original",id":"1"}},
],
"arts":[
{"stream":{"type":"art","size":"original","id":"4"}},
{"stream":{"type":"art","size":"medium","id":"9"}},
]
}
]
Run Code Online (Sandbox Code Playgroud)
和以下C#对象
class Item
{
public string Name { get; set; }
public List<Stream> References { get; set; }
public List<Stream> Arts { get; set; }
public Item()
{
}
}
class Stream
{
public string Type { get; set; }
public string Size { get; set; }
public string Id { get; set; }
public Stream()
{
}
}
Run Code Online (Sandbox Code Playgroud)
和以下代码
Item item = JsonConvert.DeserializeObject<Item>(jsonString);
Run Code Online (Sandbox Code Playgroud)
当我运行代码时,它克隆了正确数量的引用和arts,但每个流都有null值(type = null,size …
我正在尝试使用XML :: Simple CPAN模块将我们数据库的输出转换为简单的XML结构.问题是,无论我尝试传递给XML :: Simple的选项,返回的输出都不是我所希望的.
我们尝试输出的数据库表只是一堆带有定义的项目:
CREATE TABLE `items` (
`id` int(8) NOT NULL,
`name` varchar(40) NOT NULL,
`manufacturer` varchar(40) NOT NULL,
`added` datetime NOT NULL,
PRIMARY KEY (`id`)
);
Run Code Online (Sandbox Code Playgroud)
这是我们目前使用的Perl代码:
my $SQL = qq| select * from items |;
my $sth = main::DatabaseQuery($SQL);
my $items;
my $count = 0;
while(my $item = $sth->fetchrow_hashref()) {
$items->[$count] = $item;
$count++;
}
require XML::Simple;
my $xs = XML::Simple->new(ForceArray => 1, KeepRoot => 1);
my $xml = $xs->XMLout($ref);
Run Code Online (Sandbox Code Playgroud)
这将输出以下XML:
<anon id="10000" name="Item …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用控制台应用程序从图像中读取像素:
#include <QtCore/QCoreApplication>
#include <QtGui/QImage>
#include <iostream>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QImage *img = new QImage("adadad.jpg");
//std::cout << "Type filename:" << std::endl;
img->isNull();
return a.exec();
}
Run Code Online (Sandbox Code Playgroud)
这不起作用我得到了:(IT不编译,但无论如何文件还不存在......)
File not found: tmp/obj/debug_shared/main.o:: In function `main':
Run Code Online (Sandbox Code Playgroud)
到底是怎么回事?是否无法在控制台应用程序中使用Qimage?!
编辑: 屏幕
我想启动一个具有提升权限但具有隐藏窗口的子进程(实际上是相同的控制台应用程序).
我做下一个:
var info = new ProcessStartInfo(Assembly.GetEntryAssembly().Location)
{
UseShellExecute = true, // !
Verb = "runas",
};
var process = new Process
{
StartInfo = info
};
process.Start();
Run Code Online (Sandbox Code Playgroud)
这工作:
var identity = new WindowsPrincipal(WindowsIdentity.GetCurrent());
identity.IsInRole(WindowsBuiltInRole.Administrator); // returns true
Run Code Online (Sandbox Code Playgroud)
但是UseShellExecute = true创建了一个新窗口,我也无法重定向输出.
所以我下次做的时候:
var info = new ProcessStartInfo(Assembly.GetEntryAssembly().Location)
{
RedirectStandardError = true,
RedirectStandardOutput = true,
UseShellExecute = false, // !
Verb = "runas"
};
var process = new Process
{
EnableRaisingEvents = true,
StartInfo = info
};
DataReceivedEventHandler actionWrite …Run Code Online (Sandbox Code Playgroud) 在Git中,当主机使用不同的SSH端口时,如何添加远程源服务器?
git remote add origin ssh://user@host/srv/git/example
Run Code Online (Sandbox Code Playgroud) 我正在开发一个小项目,我想使用国际化.问题是,当我尝试使用内部带有西里尔符号的.properties文件时,文本显示为垃圾.当我对字符串进行硬编码时,它显示得很好.
这是我的代码:
ResourceBundle labels = ResourceBundle.getBundle("Labels");
btnQuit = new JButton(labels.getString("quit"));
Run Code Online (Sandbox Code Playgroud)
在我的.properties文件中:
退出=Изход
而且我得到了垃圾.当我尝试
btnQuit = new JButton("?????);
Run Code Online (Sandbox Code Playgroud)
它显示正确.据我所知,UTF-8是用于文件的编码.
有任何想法吗?
我正在开发一个.NET手机应用程序,我在其中有一个显示给用户的内存中的项目列表.当用户点击用户界面中的项目时,他们将被带到第二个视图中该项目的"详细信息"视图.我目前正在我的班级中使用身份属性来引用列表中的唯一项目,但我想知道是否有更好的方法.
我正在System.Windows.Navigation设置UriMappings如下:
<nav:UriMapping Uri="/Items/{itemId}"
MappedUri="/Views/Items.xaml?itemId={itemID}" />
Run Code Online (Sandbox Code Playgroud)
然后我使用NavigationService这样导航:
NavigationService.Navigate(new Uri("/Items/" + item.id.ToString(),
UriKind.Relative));
Run Code Online (Sandbox Code Playgroud)
所有这些都很有效,但我不知道我喜欢为我的Item类包含一个标识列,以便可以将唯一的字符串标识传递给MappedUri查询字符串.我显示列表的用户界面控件为我提供Item了SelectionChanged事件中的底层对象,所以我想知道是否有一种方法可以将该Item对象与唯一的字符串值"匹配" 到列表中的相应引用.如果我可以提供导航服务的简单对象引用,这将很容易,但我不知道如何使用字符串值.这是什么GetHashCode(),如果是的话,我该如何正确使用它?
mailer.php
<?php
if(isset($_POST['submit'])) {
$to = "abc@gmail.com";
$subject = "Contact via website";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];
$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";
echo "1";
echo "Data has been submitted to $to!";
mail($to, $subject, $body);
} else {
echo "0";
}
?>
Run Code Online (Sandbox Code Playgroud)
jquery代码
$('.submit').click(function(){
$('span.msg').css({'visibility': 'visible'}).text('Sending...');
$.post("mailer.php", $(".contactPage").serialize(),
function(data){
$('span.msg').text((data == "1") ? 'Your Message has been received. Thank you' : "Could not send your message at this time").show();
});
return false;
});
Run Code Online (Sandbox Code Playgroud)
我总是得到 …
制作密码/登录界面的最佳方法是什么?我知道在哪里使用弹出控件更好.如果是这样,我需要在App.xaml中创建它吗?
c# ×3
.net ×1
c++ ×1
django ×1
django-forms ×1
eclipse ×1
git ×1
java ×1
json.net ×1
perl ×1
php ×1
port ×1
qt ×1
qt-creator ×1
silverlight ×1
ssh ×1
uac ×1
xml ×1
xml-simple ×1