Django queryset returns different results from shell and server?

Maybe that's because your production database engine is different of your dev one (I assume you are running manage. Py shell on your local machine)?

Up vote 0 down vote favorite share g+ share fb share tw.

I have a Django queryset that gets different results in different situations and I am confused. Texts = Text.objects. Filter(keywords__icontains=word) The model: class Text(models.

Model): views = models. IntegerField(default=0) keywords = models. CharField(max_length=250) response = models.

CharField(max_length=140) That call, literally copied, gets the expected results with . /manage. Py shell, but doesn't find anything on the server.

It pulls up the result when I call Text.objects.all(), but for some reason the filter, on the server, doesn't find the same result as any other case. WHY? Django django-models django-queryset queryset link|improve this question asked Dec 22 '11 at 14:19sambacore133 25% accept rate.

Is this on the same machine with the same settings. Py file? If not have you run syncdb on both machines?

– mtnpaul Dec 22 '11 at 14:52 1 how are you defining word on your server (probably in your views. Py)? I bet your problem lies there.

– j_syk Dec 22 '11 at 16:54 They are on the same machine, using the same settings.py. – sambacore Dec 23 '11 at 1:06 And I am defining word with identical processes in each case, receiving a string in a phrase which I then retrieve the first word with word = body. Split(' ')0.

Is there a better way to get the first word of a string? – sambacore Dec 23 '11 at 1:16.

Maybe that's because your production database engine is different of your dev one (I assume you are running manage. Py shell on your local machine)? Keep in mind that the behaviour - especially on string matching - may differ according to your database backend.

Or maybe the content of your databases are differents? If manage. Py shell hits the same database, the results should be identicals.

Are you sure that your request (from the Webserver) is correct? Check your database logs.

I am doing both on the same server, with the same database and backend. Like I said, objects.all() includes the object I am looking for, with all the right attributes, but when filtering for it, it doesn't come up, on the production site only. – sambacore Dec 23 '11 at 1:18.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions