我正在管理ModelForm上的'clean'做一些事情:
class MyAdminForm(forms.ModelForm):
def clean(self):
# Some stuff happens...
request.user.message_set.create(message="Some stuff happened")
class MyAdmin(admin.ModelAdmin):
form = MyAdminForm
Run Code Online (Sandbox Code Playgroud)
除了threadlocals hack之外 - 我如何访问request.user来设置消息?我无法将其传递给表单构造函数,因为不会从我的代码中调用它.
我们即将开始一个项目并准备开发环境.我正在寻找使用github和Visual Studio 10的可能性.
那么github有一个Visual Studio Addin吗?
我不是在谈论社区的规模,只想听听那些实际使用过这两者的人.
特别是我对以下内容感兴趣:
我要做的是打开目录中的每个文本文件,逐行读取,如果它与特定内容匹配,请执行正则表达式并将其输出到结果.出于某种原因,我的文本文件最终成为unicode ....,不确定不知道为什么.所以我能够解决这个问题,但我无法解决我所拥有的流阅读器问题.如果有人可以建议一种方法来解决这个问题,那就太好了,如果这种方式是转换那些文本文件,那就这样吧.
继承人代码:
public void doSomeWork()
{
DirectoryInfo dinfo = new DirectoryInfo(@"C:\Documents and Settings\123");
FileInfo[] Files = dinfo.GetFiles("*.txt");
foreach (FileInfo filex in Files)
{
string line;
StreamReader sr = File.ReadAllText(filex.FullName, Encoding.Unicode);
StreamWriter sra = File.AppendText(@"C:\sharename.txt");
int counter = 0;
while((line = sr.ReadLine()) != null)
{
string matchingcontants = "Share";
if (line.Contains(matchingcontants))
{
string s = sr.ReadLine();
string sharename = Regex.Match(line, @"\+(\S*)(.)(.*)(.)").Groups[3].Value;
sra.WriteLine(sharename);
}
counter++;
}
sr.Close();
sra.Close();
}
Run Code Online (Sandbox Code Playgroud) 是否有任何情况下绝对有必要在JavaScript中对String进行显式转换
在以下示例中,没有必要:
var n=1;
var s = "Hello" + n;
var s = "Hello"+String(n); //not necessary
Run Code Online (Sandbox Code Playgroud)
我使用了上面的数值,虽然这不仅仅适用于数字.
在Windows平台上使用MSYS时,我"设置-o vi"以使用vi shell模式.文件和目录的选项卡自动完成功能停止工作.如何在保持vi shell模式的同时将其重命名?
在(UIElement)XamlReader.Load(...)期间出现异常
'Cannot create unknown type 'TextBox'.' Line number '1' and line position '2'.
Run Code Online (Sandbox Code Playgroud)
在以下xaml上:
<TextBox Name="inputMyFirstString" BorderThickness="0" HorizontalAlignment="Stretch" Text="test"></TextBox>
Run Code Online (Sandbox Code Playgroud)
我怎么了
假设我有带有查询字符串参数的URL,如下所示:
/index.php?book=DesignPatterns&page=139
/index.php?book=Refactoring&page=285
Run Code Online (Sandbox Code Playgroud)
使用mod_rewrite,如何将它们重定向到这些SES URL?
/DesignPatterns/139
/Refactoring/285
Run Code Online (Sandbox Code Playgroud) 我的mysql服务器仍然遇到问题.似乎自从我对它进行优化后,这些表格正在增长,现在有时会再次变慢.我不知道如何优化更多.
mySQL服务器有48GB的RAM,而mysqld大约使用8,大多数表都是innoDB.
网站有大约2000个在线用户.我还对每个查询运行解释,并且每个查询都被编入索引.
mySQL进程:http: //www.pik.ba/mysqlStanje.php
my.cnf文件:
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see …Run Code Online (Sandbox Code Playgroud) c# ×2
apache ×1
bash ×1
cassandra ×1
casting ×1
database ×1
dataset ×1
django ×1
django-admin ×1
django-forms ×1
github ×1
innodb ×1
javascript ×1
mod-rewrite ×1
msys ×1
mysql ×1
nosql ×1
optimization ×1
query-string ×1
r ×1
regex ×1
statistics ×1
stream ×1
string ×1
unicode ×1
vi ×1
voldemort ×1
xaml ×1