我有这个查询我试图运行但我一直遇到这个错误.我试图做一个Where将数据(BLOB列)与:var2(blob对象)进行比较的子句.
这是我的代码.
SELECT max(id)
INTO :var1
FROM table_name
where data = :var2;
Run Code Online (Sandbox Code Playgroud)
为什么我会收到此ORA-00932错误的任何建议?
我比较a blob到a blob column,应该不是很好吗?
谢谢
我正在尝试制作一个表格,显示计划中每个金融机构的总到期金额.
计划是我用于人的术语.因此每个人都可以进行多项投资.我在创建一个能够正确执行此操作的表时遇到问题.
目前我有一份报告显示按到期日分类的每项投资,即2011,2012等.
在底部我想放置这个摘要表,但我的查询显示每个金融机构的重复,因为能够进行多次投资.
我目前的查询:
list = Investment.objects.all().filter(plan = plan).order_by('financial_institution').filter(maturity_date__gte= '%s-1-1' % current_year).distinct()
Run Code Online (Sandbox Code Playgroud)
这将输出:
但我想:
我试图在我的模板上的for循环中显示图像和名称.
这就是我在我的模板for循环中所拥有的,我认为它应该可行,但事实并非如此
{% for op in tracked_objects %}
{% if op.is_mine %}
<div style="float:left;">
<div>
<img src="{{ op.tracked_object.image }}" alt="">
<a href='{% url track-profile op.tracked_object.id %}'>{{ op.tracked_object }}</a><br>
</div>
</div>
{% endif %}
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
我知道op.is_mine是真的,因为名字显示.
这是我的views.py:
@login_required
def profile(request):
user = request.user
tracked_objects = user.tracked_object_perms.all().order_by('is_mine',)
context = {
'tracked_objects':tracked_objects,
}
return render_to_response( 'accounts/profile.html' , RequestContext(request, context))
Run Code Online (Sandbox Code Playgroud)
最后是models.py
name = models.CharField(max_length='140')
image = models.ImageField(upload_to='img/tracked_object_images', null=True, blank=True)
Run Code Online (Sandbox Code Playgroud)
更新
现在当我使用下面的anser将.url添加到最后时,我得到了三个破碎的图像图标.现在我检查了路径并找到了正确的图像.这可能是服务器问题吗?或类似的规定?
这真的不应该这么难,但由于某种原因我似乎无法得到它.
我试图在我的查询上运行一个过滤器,用于比较今天和明年第一天之间的日期范围.
今天获得是没有问题的,但我似乎无法在明年的第一天获得.我希望能够为自己提供2013年1月1日
到目前为止,这是我的过滤器:
cur_il = Investment.objects.all().filter(plan = plan).order_by('financial_institution').filter(maturity_date__range=[now, nextyear])
Run Code Online (Sandbox Code Playgroud)
显然我用它来得到今天的日期:
now = datetime.now()
Run Code Online (Sandbox Code Playgroud)
我怎样才能获得下一次约会?
嘿大家,过去几天我在试图解决我的问题时得到了一些惊人的帮助.我只有最后一个问题(我希望):)
我试图从我的xml中获取最后一个元素并将其放在一个变量中.我正在使用django,python和lxml库.
我想要做的是,浏览我从API调用中获得的XML,找到最新的项目(它将具有最大的ID号),然后将其分配给存储在我的数据库中的变量.我在找到如何找到最新,最新的元素时遇到了一些麻烦.
这是一段代码:
req2 = urllib2.Request("http://web_url/public/api.php?path_info=/projects&token=#########")
resp = urllib2.urlopen(req2)
resp_data = resp.read()
if not resp.code == '200' and resp.headers.get('content-type') == 'text/xml':
# Do your error handling.
raise Exception('Unexpected response',req2,resp)
data = etree.XML(resp_data)
#assigns the api_id to the id at index of 0 for time being, using the // in front of project makes sure that its looking at the correct node inside of the projects structure
api_id = int(data.xpath('//project/id/text()')[0])
project.API_id = api_id
project.save()
Run Code Online (Sandbox Code Playgroud)
从现在开始,它将元素放在[0]并存储ID就好了,但我需要最新的/最新的/ etc元素.
谢谢,
史蒂夫
我试图添加一些值,但有些值具有NoneType值.现在我看了这个问题,但我需要一些帮助.我希望有人可以向我解释如何让这个与django一起工作.
这是我在views.py中的for循环:
next_il = Investment.objects.all().filter(plan = plan).order_by('financial_institution').filter(maturity_date__year=next_year)
for inv in next_il:
total_m2 += inv.maturity_amount
Run Code Online (Sandbox Code Playgroud)
现在,inv.maturity_amount是我试图处理的具有NoneType的值.
任何建议将不胜感激.
谢谢.
史蒂夫