我有以下型号:
class Volunteer(models.Model):
first_name = models.CharField(max_length=50L)
last_name = models.CharField(max_length=50L)
email = models.CharField(max_length=50L)
gender = models.CharField(max_length=1, choices=GENDER_CHOICES)
class Department(models.Model):
name = models.CharField(max_length=50L, unique=True)
overseer = models.ForeignKey(Volunteer, blank=True, null=True)
location = models.CharField(max_length=100L, null=True)
class DepartmentVolunteer(models.Model):
volunteer = models.ForeignKey(Volunteer)
department = models.ForeignKey(Department)
assistant = models.BooleanField(default=False)
keyman = models.BooleanField(default=False)
captain = models.BooleanField(default=False)
location = models.CharField(max_length=100L, blank=True, null=True)
Run Code Online (Sandbox Code Playgroud)
我想查询没有志愿者分配给他们的所有部门.我可以使用以下查询执行此操作:
SELECT
vsp_department.name
FROM
vsp_department
LEFT JOIN vsp_departmentvolunteer ON vsp_department.id = vsp_departmentvolunteer.department_id
WHERE
vsp_departmentvolunteer.department_id IS NULL;
Run Code Online (Sandbox Code Playgroud)
是否有更像django的方式这样做或者我应该使用原始sql?
使用jQuery DataTables时,是否可以在使用过滤器时进行不区分重音的搜索?例如,当我输入'e'字符时,我想用'e'或'é','è'搜索每个单词.
我想到的是将字符串规范化并将它们放入一个单独的隐藏列中,但这并不能解决字母顺序问题.
我尝试了以下方法:
$.fn.dataTableExt.ofnSearch = function ( data ) {
return ! data ?
'' :
typeof data === 'string' ?
data
.replace( /\n/g, ' ' )
.replace( /á/g, 'a' )
.replace( /é/g, 'e' )
.replace( /í/g, 'i' )
.replace( /ó/g, 'o' )
.replace( /ú/g, 'u' )
.replace( /ê/g, 'e' )
.replace( /î/g, 'i' )
.replace( /ô/g, 'o' )
.replace( /è/g, 'e' )
.replace( /ï/g, 'i' )
.replace( /ü/g, 'u' )
.replace( /ç/g, 'c' ) : …Run Code Online (Sandbox Code Playgroud) javascript jquery non-ascii-characters accent-insensitive jquery-datatables
我有一个Django项目,我正在使用视图来处理不同的HTTP方法.该POST处理的对象的创建,然后重定向到同一个视图作为GET(或因此我认为),使用Django的redirect()快捷方式(HTTPResponseRedirect)返回新创建的对象.这很好.我尝试了同样的事情,PUT但我陷入了重定向循环.在我挠了一会儿后,我偶然发现了这个SO答案,然后我推断,由于重定向不处理POST数据,请求变成了一个GET.
当我从以下位置进行重定向时,我通过观察日志来确认这一点POST:
[15/Dec/2014 00:47:43] "POST /client/151/ HTTP/1.1" 302 0
[15/Dec/2014 00:47:43] "GET /client/151/ HTTP/1.1" 200 395
Run Code Online (Sandbox Code Playgroud)
然而,PUT停留a PUT并将我引入重定向循环,直到它出错.
[14/Dec/2014 23:07:36] "PUT /api/asset/6779 HTTP/1.1" 301 0
[14/Dec/2014 23:07:37] "PUT /api/asset/6779/ HTTP/1.1" 302 0
[14/Dec/2014 23:07:37] "PUT /api/asset/6779 HTTP/1.1" 301 0
[14/Dec/2014 23:07:38] "PUT /api/asset/6779/ HTTP/1.1" 302 0
[14/Dec/2014 23:07:38] "PUT /api/asset/6779 HTTP/1.1" 301 0
[14/Dec/2014 23:07:39] "PUT /api/asset/6779/ HTTP/1.1" 302 …Run Code Online (Sandbox Code Playgroud) python django http http-status-code-301 http-status-code-302
相同的脚本不同的错误 这可能与我的网络而不是我的代码有关.脚本如下:
#!/usr/bin/env ruby -rubygems
require File.join(File.dirname(__FILE__), 'authentication')
require "csv" # faster_csv (ruby 1.9)
lines = CSV.read(File.join(File.dirname(__FILE__), 'karaoke.csv')) # Exported an Excel file as CSV
lines.slice!(0) # remove header line
collection = StorageRoom::Collection.find('collection ID')
Song = collection.entry_class
lines.each do |row|
karaoke = Song.new(:artist => row[0], :song => row[1], :genre => row[2], :file => StorageRoom::File.new_with_filename("#{karaoke.artist}#{karaoke.song}.mov"))
if karaoke.save
puts "Song saved: #{karaoke.artist}, #{karaoke.song}, #{karaoke.genre}"
else
puts "Song could not be saved: #{karaoke.errors.join(', ')}"
end
end
Run Code Online (Sandbox Code Playgroud)
错误是:
/usr/local/lib/ruby/1.9.1/net/protocol.rb:140:in `rescue in rbuf_fill': Timeout::Error (Timeout::Error) …Run Code Online (Sandbox Code Playgroud) 我安装xhtml2pdf使用pip与Django的使用.我收到以下ImportError:
Reportlab Toolkit Version 2.2 or higher needed
Run Code Online (Sandbox Code Playgroud)
但我有reportlab 3.0
>>> import reportlab
>>> print reportlab.Version
3.0
Run Code Online (Sandbox Code Playgroud)
我发现这个try catch块中__init__.py的xhtml2pdf:
REQUIRED_INFO = """
****************************************************
IMPORT ERROR!
%s
****************************************************
The following Python packages are required for PISA:
- Reportlab Toolkit >= 2.2 <http://www.reportlab.org/>
- HTML5lib >= 0.11.1 <http://code.google.com/p/html5lib/>
Optional packages:
- pyPDF <http://pybrary.net/pyPdf/>
- PIL <http://www.pythonware.com/products/pil/>
""".lstrip()
log = logging.getLogger(__name__)
try:
from xhtml2pdf.util import REPORTLAB22
if not REPORTLAB22:
raise ImportError, "Reportlab Toolkit Version 2.2 …Run Code Online (Sandbox Code Playgroud) 我的应用程序在混淆之前工作正常,但是当我启用proguard时,我收到以下错误:
2013-05-02 13:43:58.772 E 30138/AndroidRuntime: FATAL EXCEPTION: main java.lang.NumberFormatException: Invalid long: "0.20"
at java.lang.Long.invalidLong(Long.java:125)
at java.lang.Long.parse(Long.java:362)
at java.lang.Long.parseLong(Long.java:353)
at java.lang.Long.parseLong(Long.java:319)
at com.sourcetone.data.model.Station.long getId()(SourceFile:195)
at com.sourcetone.STStationListFragment.void deleteStation(com.sourcetone.data.model.Station)(SourceFile:298)
at com.sourcetone.STStationListFragment.void access$4(com.sourcetone.STStationListFragment,com.sourcetone.data.model.Station)(SourceFile:293)
at com.sourcetone.STStationListFragment$ArrayListAdapter$1.void onClick(android.view.View)(SourceFile:274)
at android.view.View.performClick(View.java:3528)
at android.view.View$PerformClick.run(View.java:14217)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4482)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:561)
at dalvik.system.NativeStart.main(Native Method)
2013-05-02 13:43:58.803 W 472/ActivityManager: Force finishing activity com.sourcetone/.STMainActivity
Run Code Online (Sandbox Code Playgroud)
我的proguard配置有以下内容:
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
Run Code Online (Sandbox Code Playgroud)
那么Parcelable应该保持正确吗?它投掷的无效长度实际上是我请求的另一部分,所以它正在读取错误的数字.我是否还必须保留我的HttpResponse课程?还有什么呢?
我正在尝试使用WSGI为Apache上的特定目录设置Python,但是我收到以下错误:
mod_wsgi (pid=3857): Target WSGI script '/var/www/test/test.py' does not contain WSGI application 'application'.
Run Code Online (Sandbox Code Playgroud)
我的test.py包含:
print 'Hello, World!'
Run Code Online (Sandbox Code Playgroud)
我的wsgi.conf包含:
LoadModule wsgi_module modules/mod_wsgi.so
WSGIPythonHome /usr/local/bin/python2.7
Alias /test/ /var/www/test/test.py
<Directory /var/www/test>
SetHandler wsgi-script
Options ExecCGI
Order deny,allow
Allow from all
</Directory>
Run Code Online (Sandbox Code Playgroud)
最重要的是,有趣的是,Web浏览器返回"404 Not Found"错误,但幸运的是error_log更具启发性.
我究竟做错了什么?
我的应用程序运行完美,没有启用proguard但是当我启用它时,应用程序立即崩溃.我在配置中尝试了很多组合无济于事.
有什么东西我应该保留,我失踪了吗?
proguard config:https://gist.github.com/hanleyhansen/99fc07807950bae8e4f5
未经模糊处理的日志:https://gist.github.com/hanleyhansen/6cba7fc941a79d85802f
onSuccess():https://gist.github.com/hanleyhansen/e7a4916c42d3ca065c99
我可以在Drupal模板文件中使用令牌替换吗?我正在尝试这个:
$author_uid = "[node:author:uid]";
$nid = "[node:nid]";
Run Code Online (Sandbox Code Playgroud)
但它不起作用.如何在node.tpl.php模板中正确使用令牌替换?
在变量中存储令牌替换的正确方法是什么?或者我应该打扰并直接打电话给他们?
像:
$author_uid = [node:author:uid];
$name = [node:title];
$picture = [node:field-image-upload:file];
$link = [node:url];
Run Code Online (Sandbox Code Playgroud)
给我一个错误:
PHP Parse error: syntax error, unexpected ':'
Run Code Online (Sandbox Code Playgroud)
难道我做错了什么?
还有关于这一行:
$picture = [node:field-image-upload:file];
Run Code Online (Sandbox Code Playgroud)
我真正想要得到的是该图像文件的url链接.如何使用令牌执行此操作?
python ×4
django ×3
android ×2
drupal-7 ×2
java ×2
obfuscation ×2
php ×2
proguard ×2
django-orm ×1
eclipse ×1
http ×1
javascript ×1
jquery ×1
mod-wsgi ×1
parcelable ×1
pip ×1
python-2.7 ×1
reportlab ×1
ruby ×1
sql ×1
token ×1
wsgi ×1
xhtml2pdf ×1