English 中文(简体)
Django, databaseretrieval not working but delet areas and Plus new areas is working
原标题:Django, database retrieval not working but deleting fields and adding new fields is working

我已经获得我的数据库查询,以便适当开展工作,删除现有条目,并在数据库中增加新的条目,但我完全不了解我为何无法从我的数据库中收回任何东西。 我正在尝试这样一个问题:

from web1.polls.models import Poll
retquery = Poll.objects.all()
print retquery
--prints: "[ ]"

而且,如果我尝试这样做,它只是回报“污染物体”。

from web1.polls.models import Poll
retquery = Poll.objects.all()[0]
print retquery
--prints: "poll object"

我审视了所有情况,数据库中无疑有条目,我尝试采用一些不同的模式,其他一切都在做其他工作,因此我不知道我现在可以做些什么,我们非常赞赏任何建议。

最佳回答

如果有的话,请提供<代码>的统一代码__。 你们的榜样是,你没有问题。

http://www.djangoproject.com/documentation/models/str/
问题回答

最后,我要说的是,我是这样说的,因为如果Django s docs t没有说明这一点,那么,我就真的混淆了象我这样的人,因为Django s docs t没有说明这一点,我用来印刷一个物体,并且把所有物体列入其中,但出于某种原因,返回的物体类型不是这样,这样做会奏效,因此,你需要把由此而产生的变数计算出来,并最后添加实地的名称,以便进入:

If I have a field named "question" that I want to retrieve:
retquery = Poll.objects.all()
print retquery.question

这将奏效,而我在这样做之前只印制任何东西,使我想被退回的物体是空洞的。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签