Re: Passenger 57 - a Django query problem

2010-02-16 Thread Emily Rodgers
ance) > > So, if Passenger 57 books a flight with, say, AIA, which is a member of the > Star and Western alliances, how can I tell if this qualifies for a > discount?  Assume, for purpose of this query, that the logged in user_id is > the same as the passenger_id (i.e. 57). How ab

Re: Passenger 57 - a Django query problem

2010-02-16 Thread Emily Rodgers
On Feb 16, 3:39 pm, bruno desthuilliers wrote: > On Feb 16, 2:56 pm, Derek wrote: [snip] > Ain't that "memberships" relationship redundant with passenger->flight- > > >operator->memberships ? I reckon he probably wants to do is split passenger up: class Passenger(models.Model): customer =

Re: Passenger 57 - a Django query problem

2010-02-16 Thread bruno desthuilliers
On Feb 16, 4:54 pm, Emily Rodgers wrote: > On Feb 16, 3:39 pm, bruno desthuilliers > > wrote: > > On Feb 16, 2:56 pm, Derek wrote: > [snip] > > Ain't that "memberships" relationship redundant with passenger->flight- > > > >operator->memberships ? > > I reckon he probably wants to do is split pas

Re: Passenger 57 - a Django query problem

2010-02-17 Thread Emily Rodgers
oup together to give some kind of club that customers can sign up to to get benefits of discounts from all companies in the group (reward cards are the most obvious case I can think of). If this is Derek's meaning then the passenger (or I think user) may have memberships to any number of such r

Re: Passenger 57 - a Django query problem

2010-02-17 Thread bruno desthuilliers
On Feb 17, 10:12 am, Emily Rodgers wrote: > On Feb 16, 4:50 pm, bruno desthuilliers > > I'm afraid I don't really get what difference it would make. Note that > > my question was genuine - I know zilch about the problem domain, I > > don't have the fisrt clue about what an "Alliance" might be, so

Re: Passenger 57 - a Django query problem

2010-02-17 Thread Emily Rodgers
tor/ > > > memberships link. > > > My assumptions > (snip) > > If this is Derek's meaning then > (snip) > >  Also, and > > airline may be > > (snip) > > Sorry but that's WAY too much assumptions for me. I don't do wild- > guess

Re: Passenger 57 - a Django query problem

2010-02-17 Thread bruno desthuilliers
On 17 fév, 17:29, Emily Rodgers wrote: > As I said, we aren't doing his coding for him, And as I said, this is _not_ the problem. I don't mind providing working code as an answer, and did it on quite a few occasions during the past 10 years or so, on various newsgroups and mailing lists. But c

Re: Passenger 57 - a Django query problem

2010-02-17 Thread Sithembewena Lloyd Dube
Emily provided an answer according to what she understood from the OP. No harm in doing that, at least not worse than no attempt at giving a solution.. This is not a parade for anyone's personal coding style: attempt to help, or stay away. Lloyd On Wed, Feb 17, 2010 at 1:20 PM, bruno desthuillie

Re: Passenger 57 - a Django query problem

2010-02-17 Thread Sithembewena Lloyd Dube
Emily provided an answer according to what she understood from the OP. No harm in doing that, at least not worse than no attempt at giving a solution.. I think that people who have a problem with posts, even vague ones, should stay away from them - let those that would try to help, to do so unhind

Re: Passenger 57 - a Django query problem

2010-02-17 Thread Sithembewena Lloyd Dube
Emily provided an answer according to what she understood from the OP. No harm in doing that, at least not worse than no attempt at giving a solution.. I suspect this is more plausible than philosophising away all night. On Thu, Feb 18, 2010 at 12:00 AM, bruno desthuilliers < bruno.desthuilli...@

Re: Passenger 57 - a Django query problem

2010-02-17 Thread Sithembewena Lloyd Dube
Emily provided an answer according to what she understood from the OP. No harm in doing that, at least not worse than no attempt at giving a solution. We have no interest in your personal coding style: attempt to help, or zip your gob. Have had it with egomaniacs running loose.. Lloyd On Thu, Fe

Re: Passenger 57 - a Django query problem

2010-02-17 Thread Sithembewena Lloyd Dube
Emily provided an answer according to what she understood from the OP. No harm in doing that, at least not worse than no attempt at giving a solution.. I suspect this is more plausible than philosophising away all night. On Thu, Feb 18, 2010 at 12:00 AM, bruno desthuilliers < bruno.desthuilli...@

Re: Passenger 57 - a Django query problem

2010-02-17 Thread Sithembewena Lloyd Dube
Emily provided an answer according to what she understood from the OP. No harm in doing that, at least not worse than no attempt at giving a solution.. To me, this is more plausible than philosophising away all night. Lloyd On Thu, Feb 18, 2010 at 12:00 AM, bruno desthuilliers < bruno.desthuilli

Re: Passenger 57 - a Django query problem

2010-02-17 Thread Sithembewena Lloyd Dube
Emily provided an answer according to what she understood from the OP. No harm in doing that, at least not worse than no attempt at giving a solution.. I suspect this is more plausible than philosophising away all night. On Thu, Feb 18, 2010 at 12:00 AM, bruno desthuilliers < bruno.desthuilli...@

Re: Passenger 57 - a Django query problem

2010-02-18 Thread bruno desthuilliers
On Feb 17, 11:32 pm, Sithembewena Lloyd Dube wrote: > Emily provided an answer according to what she understood from the OP. No > harm in doing that, > at least not worse than no attempt at giving a > solution.. I wouldn't have asked for precisions if I didn't intend to try and help. > This is n

Re: Passenger 57 - a Django query problem

2010-02-18 Thread Atamert Ölçgen
Hi Sithembewena, On Thursday 18 February 2010 00:27:10 Sithembewena Lloyd Dube wrote: > Emily provided an answer according to what she understood from the OP. No > harm in doing that, at least not worse than no attempt at giving a > solution.. > > I think that people who have a problem with post

Re: Passenger 57 - a Django query problem

2010-02-18 Thread Sithembewena Lloyd Dube
Apologies for my handling of this matter earlier. It was not the Python way :) Bruno, feel welcome here. On Thu, Feb 18, 2010 at 11:25 AM, Atamert Ölçgen wrote: > Hi Sithembewena, > > > On Thursday 18 February 2010 00:27:10 Sithembewena Lloyd Dube wrote: > > Emily provided an answer according

Re: Passenger 57 - a Django query problem

2010-02-18 Thread Emily Rodgers
On Feb 18, 9:25 am, Atamert Ölçgen wrote: > Hi Sithembewena, > > On Thursday 18 February 2010 00:27:10 Sithembewena Lloyd Dube wrote:> Emily > provided an answer according to what she understood from the OP. No > > harm in doing that, at least not worse than no attempt at giving a > > solution.

Re: Passenger 57 - a Django query problem

2010-02-19 Thread Sithembewena Lloyd Dube
I hope that we can all learn somehow from the incident. When i reacted the way i did, i was picking up subtle undertones of aggression which i thought were undue. I have since spoke to Bruno and diffused the situation amicably. I would agree with what Emily says, and the things I take away from it

Re: Passenger 57 - a Django query problem

2010-02-19 Thread bruno desthuilliers
On 18 fév, 12:03, Sithembewena Lloyd Dube wrote: > Apologies for my handling of this matter earlier. It was not the Python way > :) > > Bruno, feel welcome here. > Ok, I'm back then !-) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post t

Re: Passenger 57 - a Django query problem

2010-02-19 Thread bruno desthuilliers
On 18 fév, 12:16, Emily Rodgers wrote: (snip) > I think he stopped helping when he started using phrases like 'crystal > ball' and 'wild-guess programming'. They are hostile responses. > Emily, if you manage to stick to your wishfull words for the next ten years without even a single possibly "ho

Re: Passenger 57 - a Django query problem

2010-02-20 Thread Sithembewena Lloyd Dube
Lol..c'mon Bruno, we just resolved this. Stop attacking Emily. You admitted in your email to me that you could be, in your own words, an "asshole" sometimes, that your words were "uselessly harsh", and that Emily was right. Why come onto the thread and attack her again? I declare this matter close

Re: Passenger 57 - a Django query problem

2010-02-20 Thread Sithembewena Lloyd Dube
I wonder what Atamert the peacemaker has to say now, since the person to whose defense he came admitted he was wrong. Amazing to note that Atamert noticed my directness to Bruno, but did not notice how nasty Bruno was to other respondents (namely Emily and Derek). What have you to say, o' wise Ata

Re: Passenger 57 - a Django query problem

2010-02-20 Thread Sithembewena Lloyd Dube
So, Atamert, Bruno admitted he was wrong. What have you to say?? It's strange that you noticed i was direct with him,but you did not seem to notice how harsh he was to Emily and Derek?? Anyways, peace.. On Thu, Feb 18, 2010 at 11:25 AM, Atamert Ölçgen wrote: > Hi Sithembewena, > > > On Thursda

Re: Passenger 57 - a Django query problem

2010-02-20 Thread Russell Keith-Magee
On Sun, Feb 21, 2010 at 4:11 AM, Sithembewena Lloyd Dube wrote: > I wonder what Atamert the peacemaker has to say now, since the person to > whose defense he came admitted he was wrong. Amazing to note that Atamert > noticed my directness to Bruno, but did not notice how nasty Bruno was to > other

Re: Passenger 57 - a Django query problem

2010-02-20 Thread Steven Elliott Jr
I've always found both the Django and Python communities to be among the friendliest and most helpful. Please be kind to one another and respectful of everyones comments. We are here to support one another in our efforts to better our django skills and to better the community and project as

Re: Passenger 57 - a Django query problem

2010-02-21 Thread Sithembewena Lloyd Dube
Thank you everybody. Chapter closed. On Sun, Feb 21, 2010 at 4:11 AM, Steven Elliott Jr wrote: > I've always found both the Django and Python communities to be among the > friendliest and most helpful. Please be kind to one another and respectful > of everyones comments. We are here to support on

Re: Passenger 57 - a Django query problem

2010-02-21 Thread derek
ily may be helpful at some point) - rather I am trying to figure how to ask a question (i.e write a query) that has a True/False answer - which I would state loosely in English "does this qualify for a discount"? or, more explicitly "does the Passenger's membership of (one or mo

Re: update query set with a limit

2010-02-27 Thread James Bennett
On Sat, Feb 27, 2010 at 10:07 PM, Harley Bussell wrote: > Hi, id like to know if any one has found a work around to use limits > when updating a query set. This is unlikely to be supported by Django; "UPDATE ... LIMIT" is non-standard, non-portable and MySQL is the only DB supp

Re: newbie - query not working!! Help please!!

2010-03-07 Thread Kev Dwyer
> > model: > class Poll(models.Model): > PUBLISHED_STATUS = 1 > DARK_STATUS = 2 > STATUS_CHOICES = ( > (PUBLISHED_STATUS, 'Published'), > (DARK_STATUS, 'Dark'), > ) > poll_id = models.AutoField(primary_key=True)

Re: newbie - query not working!! Help please!!

2010-03-07 Thread uthaman
poll): > >          entry = Poll.objects.filter(poll_id=poll) > > > model: > > class Poll(models.Model): > >    PUBLISHED_STATUS = 1 > >    DARK_STATUS = 2 > >    STATUS_CHOICES = ( > >            (PUBLISHED_STATUS, 'Published'), > >        

look at about-to-be-run query

2010-04-20 Thread Jim
Hello. I have a query that is failing and I'd like to look at it. (I'm trying to do full-text searches in postgresql 8.2, so I'm using extra with both select and where clauses, so it is reasonably complex). I know how to see prior queries with connection.queries. But is there a

Re: Saving the query object for later

2010-04-28 Thread Bill Freeman
ed, Apr 28, 2010 at 10:34 AM, Mark Jones wrote: > When someone searches for something on the site and finds nothing, I > want to save that query for later reuse (so I can run it each night to > see if anything new matches their request, and email what is found to > the user). > >

Re: Saving the query object for later

2010-04-28 Thread Mark Jones
I was thinking I could pickle/unpickle the request then run it thru with an extra flag of (send email) thru the same code that wsgi uses. If I jsonify the data, how would I get that back into a python object? Is it really as simple as str=json.dumps(request) and request = json.loads(str) I don't

Re: Saving the query object for later

2010-04-28 Thread Bill Freeman
The request may have references to objects that will no longer exist, or may be inappropriate when rerun later. I can't promise that it won't work, but I believe that pickling the request is at best a fragile solution. To save just the required parameters won't take much code, especially if you r

Re: Saving the query object for later

2010-04-28 Thread Peter Landry
+1 to this. I had similar requirements, and initially went down the road of pickling a queryset. It became clear quickly that (at least in my case) a better solution was to have a function that translates a Form instance into a Queryset. Then serialize the form (or form data) and regenerate the Que

Inconsistency between DB Query Results Between Threads

2010-04-28 Thread Jared Smith
Using Django DB API I have two threads one that increments a counter getting stored to the database and then another thread that is reading this counter. T1(Thread 1) increments T2(Thread 2) reads I have found that if I increment and store the counter value in T1 and then if I fetch it in the sa

Re: Saving the query object for later

2010-04-29 Thread derek
On Apr 28, 7:45 pm, Peter Landry wrote: > +1 to this. I had similar requirements, and initially went down the road of > pickling a queryset. It became clear quickly that (at least in my case) a > better solution was to have a function that translates a Form instance into > a Queryset. Then seriali

Re: Saving the query object for later

2010-04-29 Thread Bill Freeman
function. As far as serializing the function's arguments goes, if the user object is needed, you would instead serialize user.id. The function could easily test whether the user argument is an instance of User, or an int, and optionally perform the query to get the user object. Or the code th

Re: Getting Duplicate records with Q query

2010-06-03 Thread Thomas Guettler
gt; > Model is a Note, with a created_by field and a many-to-many to a > recipients table which is itself linked to a User Profile table which > is linked to Users. > > Note <--Recipients-->UserProfile-->User > > This is the query: > > mynotes = Note.objects.filter((

annotate with query set for distinct values

2010-06-10 Thread SlafS
Hi there! I have a question. If i have a model with some fields (let's say all CharFields named aaa,bbb,ccc etc. and some calculated properties named xxx and zzz) how can I obtain something similar to "SELECT aaa, count(aaa) FROM my_model_table GROUP BY aaa;" i.e. a list of - lazy loaded - objects

custom template tags with a raw query

2010-06-14 Thread Cole743
Hello again, My last question may have been unclear, so I'm going to be more specific. I want to use the results of this: cursor.execute("SELECT * from sp_getreport(""varchar"" %s)", [usr]) (or something similar) In a custom template tag to display in a templa

Re: Making MODEL.objects.raw() query with LIKE input%

2010-11-10 Thread Daniel Roseman
On Nov 9, 10:06 pm, xvga wrote: > Hi All, > >  my question is linked to this thread, so I post here > > I need to run sql query with LIKE and % in the end - I have tried %% > and : > CLASSNAME.objects.raw("select * from table where full_name like %s%% > ",

Re: Making MODEL.objects.raw() query with LIKE input%

2010-11-10 Thread xvga
Daniel, thank you very much :) You are right, that was just an example query > user_input = "%s%%" % user_input did the trick. On Nov 10, 11:28 am, Daniel Roseman wrote: > On Nov 9, 10:06 pm, xvga wrote: > > > > > Hi All, > > >  my question is linked to

Cant find out the "OR" in query

2011-01-24 Thread nicolas lubkov
hi all is pretty simple my question. when im making a query in django i use this result = person.objects.filter(name = "nick", lastname = "smith") this is like "select * from person where name = 'nick' and lastname = 'smith i cant figure it out how to

Re: Django SQL Query does not stop

2011-02-01 Thread Tom Evans
On Tue, Feb 1, 2011 at 3:53 PM, Ivo Brodien wrote: > When I am in admin and I access of a certain model, Django calls mysql with > an Query which increases mysql CPU load to 99% and it never returns. > > If I copy the the SQL Query right into mysql the same thing happens, so it is

Re: Django SQL Query does not stop

2011-02-01 Thread Ivo Brodien
On 01.02.2011, at 16:55, Tom Evans wrote: > In the mysql shell: > > EXPLAIN SELECT ... unfortunately same problem. CPU turns to 100% and it is stuck. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django

Re: Django SQL Query does not stop

2011-02-01 Thread Ivo Brodien
The Change List that I am calling is a Intermediate Table if that is of any interest. Is it possible that there is some sort of circular inner joints or something? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send em

Re: Django SQL Query does not stop

2011-02-01 Thread Ivo Brodien
I found a solution be changing the MySQL server setting optimizer_search_depth to 3 (default 62) http://dev.mysql.com/doc/refman/5.0/en/controlling-optimizer.html http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_optimizer_search_depth My query had over 20 INNER JOINTS

RE: Django SQL Query does not stop

2011-02-01 Thread Chris Matthews
Hi Ivo, SQL is like regular expressions. You can go complex (with one mega query/expression) but it could create a maintenance nightmare. See if you cannot simplify the query into multiple queries and a bit of code (for loops and using the joining columns) to lash them together. The code

Re: Django SQL Query does not stop

2011-02-03 Thread Ivo Brodien
. You can go complex (with one mega > query/expression) but it could create a maintenance nightmare. See if you > cannot simplify the query into multiple queries and a bit of code (for loops > and using the joining columns) to lash them together. The code sequence > should be such tha

Re: Django SQL Query does not stop

2011-02-03 Thread Sergiy
ever running query from the admin. As changing db structure was not feasible I had to remove those fields from my list_display to make it useable. Also when you have a query hanging like that, inside MySQL shell you can run `show processlist` and then `kill ` to get rid of the offending query. Cheers

Re: query set on a manytomany table

2011-02-18 Thread gladys bixly
Why would you want to query the table directly? I believe the only way you could access data from a ManyToManyField is through the Model in which it is related. On Fri, Feb 18, 2011 at 11:35 AM, Bobby Roberts wrote: > I have a Manytomanyfield in a model called "registrants" on

Unexpected result from making single object query

2011-02-22 Thread mm
I am not sure what I am doing wrong but there is my code: current_entry = Entry.objects.get(id=10) next_entry = Entry.objects.get(current_entry.next) prev_entry = Entry.objects.get(current_entry.prev) where current_entry.next and current_entry.prev columns contained the name of the previous and

Admin Action - getting the 'entire' query set

2011-03-10 Thread tom
Hi, I want to be able to perform an Action on the full query set I have after filtering. Assume I have 100,000 objects on my DB. After filtering- 1,000 remain, and are divided into 10 pages of display. Now I want to delete all of them, I check the appropriate checkbox but the action 'd

Re: django remove unicode from query result ?

2011-03-10 Thread Bill Freeman
racer set. Encoding into UTF-8 might be what you want. On Thu, Mar 10, 2011 at 12:29 PM, sushanth Reddy wrote: > Hi, > > Django query gives me below output  format,but i want below format > >     date=`[{'total': 1744, 'name: u'x'}, {'total&#x

Re: django remove unicode from query result ?

2011-03-10 Thread Kenneth Gonsalves
On Thu, 2011-03-10 at 09:29 -0800, sushanth Reddy wrote: > print m > it give me output > > [[1744,u'x'], [13,u'm'], [126,u'n']] > > but i need output in > how to remove unicode symbol from output > > why do you want to remove it? unicode is a great advance - why are you going backward in

Re: django remove unicode from query result ?

2011-03-10 Thread sushanth Reddy
I using jplot in my app .if list is in unicode(u) ,it not displaying the charts,thats the reason i want to remove it ... -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsu

Re: django remove unicode from query result ?

2011-03-10 Thread Kenneth Gonsalves
On Thu, 2011-03-10 at 17:26 -0800, sushanth Reddy wrote: > I using jplot in my app .if list is in unicode(u) ,it not displaying > the > charts,thats the reason i want to remove it ... I do not think that is a good reason. Why not use a python or js library? http://wiki.python.org/moin/NumericAn

Re: django remove unicode from query result ?

2011-03-10 Thread Jason Culverhouse
On Mar 10, 2011, at 5:26 PM, sushanth Reddy wrote: > I using jplot in my app .if list is in unicode(u) ,it not displaying the > charts,thats the reason i want to remove it ... > Pass a json string then have the Java(?) side convert it back into "objects" In [1]: import json In [2]: json.dumps

Re: django remove unicode from query result ?

2011-03-11 Thread sushanth Reddy
Hi JAson, Thanks a ton,it worked -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For m

Re: Group by date: Annotate & Aggregate Query

2011-03-24 Thread Casey Greene
eated two linked (one to many) models, 'Article' with many 'Comments' - I want to know how many comments have been made on each article per day (and preferably efficiently without having to do a query per day with a specific filter). Effectively, the code tha

Re: Creating this query with django Models

2011-04-09 Thread Martin J. Laubach
Let's see... Since there is no aggregate on your outer select, the GROUP BY is basically reduced to a DISTINCT, so we can just do a distinct() on the query set. The JOINs come automatically as soon as you have ForeignKey fields (just remember to do a select_related() to avoid exce

Re: Creating this query with django Models

2011-04-11 Thread Thomas M
CT, so we can just do a distinct() on the query > set. The JOINs come automatically as soon as you have ForeignKey fields > (just remember to do a select_related() to avoid excessive queries there). > The max(status.id) inner select -- you can't get a subselect automatically, > so

Re: Creating this query with django Models

2011-04-13 Thread Martin J. Laubach
What problems did you encounter? It's easier to help you knowing what went wrong. mjl -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group,

Re: Creating this query with django Models

2011-04-13 Thread Martin J. Laubach
What problems did you encounter? It's easier to help you knowing what went wrong. mjl -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group,

Help with custom model method for query

2011-06-09 Thread Chris McComas
I have this views.py and models.py: http://dpaste.com/552615/ On the view what I want to do is display a list of all the feed types (News, Sports, etc general categories), then then below each of those feed type headings display the FeedItems for each feed for that city. Prior to adding the City

need help with calling following complex query

2011-07-10 Thread sanket
Hey All, I am quite new to Django and recently started using django for developing a location based service. In order to find the places in near by area I want to make following mysql query. but I am not sure how should I translate it using django models and managers. orig.lat = x orig.lon = y

Re: speeding up iterating over query set

2011-07-11 Thread Cal Leeming [Simplicity Media Ltd]
On Mon, Jul 11, 2011 at 2:57 PM, Michel30 wrote: > Hi all, > > I have a basic search function that uses Q objects. > After profiling it I found that the actual (mysql) database query > finishes in fractions of seconds but the iterating after this can take > up to 50 seconds

Re: speeding up iterating over query set

2011-07-11 Thread Cal Leeming [Simplicity Media Ltd]
rofiling it I found that the actual (mysql) database query >> finishes in fractions of seconds but the iterating after this can take >> up to 50 seconds per 10.000 results. >> >> I have been trying to speed it up but I have had not much results.. >> >> My

Re: speeding up iterating over query set

2011-07-11 Thread Cal Leeming [Simplicity Media Ltd]
Mon, Jul 11, 2011 at 2:57 PM, Michel30 wrote: >> >>> Hi all, >>> >>> I have a basic search function that uses Q objects. >>> After profiling it I found that the actual (mysql) database query >>> finishes in fractions of seconds but the iterating

Re: speeding up iterating over query set

2011-07-11 Thread Michel30
ltd.co.uk> wrote: > > > On Mon, Jul 11, 2011 at 2:57 PM, Michel30 wrote: > > >> Hi all, > > >> I have a basic search function that uses Q objects. > >> After profiling it I found that the actual (mysql) database query > >> finishes in fractio

Re: speeding up iterating over query set

2011-07-11 Thread Andre Terra
decided to go about it. Cheers, André Terra On Mon, Jul 11, 2011 at 10:57 AM, Michel30 wrote: > Hi all, > > I have a basic search function that uses Q objects. > After profiling it I found that the actual (mysql) database query > finishes in fractions of seconds but the iter

Re: speeding up iterating over query set

2011-07-11 Thread bruno desthuilliers
On 11 juil, 15:57, Michel30 wrote: > Hi all, > > I have a basic search function that uses Q objects. > After profiling it I found that the actual (mysql) database query > finishes in fractions of seconds but the iterating after this can take > up to 50 seconds per 10.000 result

Re: speeding up iterating over query set

2011-07-12 Thread Michel30
Hi guys, I've been trying your suggestions but I'm afraid I'm stretching the limits of my Python/Django abilities ;-) Bruno got it right: what I want is a queryset of "model" with distinct docid having the highest version number, sorted by revisiondate. If have the following result of my found_e

Re: speeding up iterating over query set

2011-07-12 Thread Michel30
Hi guys, I've been trying your suggestions but I'm afraid I'm stretching the limits of my Python/Django abilities ;-) Bruno got it right: what I want is a queryset of "model" with distinct docid having the highest version number, sorted by revisiondate. If have the following result of my found_e

Re: speeding up iterating over query set

2011-07-12 Thread Michel30
Hi guys, I've been trying your suggestions but I'm afraid I'm stretching the limits of my Python/Django abilities ;-) Bruno got it right: what I want is a queryset of "model" with distinct docid having the highest version number, sorted by revisiondate. If have the following result of my found_e

Re: speeding up iterating over query set

2011-07-12 Thread bruno desthuilliers
On Jul 12, 12:26 pm, Michel30 wrote: > Hi guys, > > I've been trying your suggestions but I'm afraid I'm stretching the > limits of my Python/Django abilities ;-) > > Bruno got it right: what I want is a queryset of "model" with distinct > docid having the highest version number, sorted by revisio

Re: speeding up iterating over query set

2011-07-12 Thread Michel30
I have tried and I think I have it mostly working: it returns ALL unique docid's. What is left is that my code is part of a search function. Originally I got normalized keywords from a user and used those Q-objects to look for keywords in a selected set of columns. I still have to figure out how

Re: speeding up iterating over query set

2011-07-12 Thread bruno desthuilliers
keywords in a selected set of columns. > > I still have to figure out how to get that into the SQL part.. With the 2-fold solution I suggested (raw SQL query to retrieve latest revisions then "normal" ORM query) you may not have to "get that into the SQL part" - just

Re: speeding up iterating over query set

2011-07-12 Thread Andre Terra
Have you looked at haystack? http://haystacksearch.org/ Cheers, André On Tue, Jul 12, 2011 at 10:49 AM, Michel30 wrote: > I have tried and I think I have it mostly working: it returns ALL > unique docid's. > > What is left is that my code is part of a search function. Originally > I got norma

Doing maths on fields in a query

2011-08-15 Thread Thorsten
Hello, I am wondering if it is possible to do math on fields inside a query with using the django syntax for example like SELECT (buyout / quantity) as buyout_per_item Currently I am using raw queries, because i couldn't find anything about such cases. Greetings, -- You received this me

Re: DatabaseError: execute used with asynchronous query

2012-03-09 Thread Daniel Svonava
> > >> I was testing one my apps today with a form that features a drop-down > >> field that initiates a json lookup for additional detail. You choose a > >> location, it populates address fields. It's been working for weeks. > >> Today, when I click

Passing a query set into a template

2012-03-17 Thread Stanwin Siow
Hello, I have the following view method: def index(request): form = OpinionOptionForm(initial={'keyword': 'singtel', 'start_date': datetime.today()-timedelta(days=7), 'end_date': datetime.today(),

Unable to get result using distance query

2012-04-25 Thread vishy
Hi, I am using PointField to store longitude and latitude with SRID 4326. All my places are in USA. Now, given a reference point, I do lat = "41.881944" lng = "-87.627778" ref_pnt = fromstr("POINT(%s %s)" % (lng, lat)) distance_from_point = {'m':'50'} r_gis

Trouble with query syntax in Django view

2012-04-30 Thread LJ
I have a Student model that stores information about a student, including the student's teacher. The teacher's information is stored in the Employee model that inherits from the Person Model. I am having trouble figuring out how to query the teacher, when a student id is passed as an aja

GET parameters and custom admin query filters

2012-05-02 Thread Daniel Sokolowski
As per 'https://docs.djangoproject.com/en/1.3/releases/1.2.4/ #restricted-filters-in-admin-interface' to be able to create GET parameters on the fly one has to add it to the `ModelAdmin.list_filter` setting. That's what I have been doing however on my latest project I am using a custom admin filt

ordering m2m query based on through table

2012-05-21 Thread KentH
I am trying to configure a m2m relationship to be ordered based on data in the through table. I assumed an 'order' attribute in the through-table's Meta class would be honored, but it's not. Bug #11850 (closed: wontfix) relates to this problem, but with no pointer as to a work-around. As custom

Re: how to suppress ForeignKey related query

2012-06-04 Thread Nikolas Stevenson-Molnar
Related objects are lazy by default, unless you're using select_related() or prefetch_related(): https://docs.djangoproject.com/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.select_related So if you're seeing a player query and you're not using one of those method

Trouble expressing a query in the ORM

2011-09-08 Thread Daniel Gagnon
Hi. I have a query I am trying to perform in the ORM and I'm not sure how to do it. I have two models: Target and Property with a one-to-many relationship. One Target can have many Properties. I want to list all targets along with their latest properties (as stored under Property.export

Re: Need advice on ForeignKey query problem.

2011-10-11 Thread Kevin
gt;     facility = models.ForeignKey(Facility) >     ... > > I would like a query that returns one record for each Facility and that > record would contain at least the id (if not more) of ALL linked > schedules.  So far I've only been able to return a queryset that > contains a recor

RE: Need advice on ForeignKey query problem.

2011-10-11 Thread Sells, Fred
= models.Facility.objects.filter(...).schedule_set.all() If there is not a "clean" method to do this, I'm inclined to use the above solution since I have only ~100 records in the first query. I don't want to "drop into SQL" unnecessarily. On this query, I probably onl

Re: DatabaseError: execute used with asynchronous query

2012-02-28 Thread Daniel Svonava
t change. > > I have debug off, so instantly I feel my phone buzz and I've been sent > a http500 report e-mail with the following message- > > > DatabaseError: execute cannot be used while an asynchronous query is > underway > > > I can't seem to reproduce the

Re: DatabaseError: execute used with asynchronous query

2012-02-28 Thread j_syk
detail field didn't change. >> >> I have debug off, so instantly I feel my phone buzz and I've been sent >> a http500 report e-mail with the following message- >> >> >> DatabaseError: execute cannot be used while an asynchronous query is >> underway

Re: Redirect to page with query string

2012-08-18 Thread Melvyn Sopacua
On 19-8-2012 2:26, Barry Morrison wrote: > I have a view that displays images and gives me the ability to delete the > images. > > View url == /account/community/images/1 (1 == event_id) Change to: . Keep passing this return_to parameter around. It helps to use the request context processor s

Re: Redirect to page with query string

2012-08-18 Thread Barry Morrison
I apologize, I'm new to Django and Python...I've tried every which way I know how based on what you described, and I can't find success. Here is what I'm at right now: http://dpaste.org/7JcGT/ I get this error: 'DeleteCommunityImages' object has no attribute 'GET' Full traceback: http://dpaste.

Re: Redirect to page with query string

2012-08-19 Thread Barry Morrison
This actually ended up working: http://dpaste.org/U0uY4/ On Saturday, August 18, 2012 5:46:28 PM UTC-7, Melvyn Sopacua wrote: > > On 19-8-2012 2:26, Barry Morrison wrote: > > I have a view that displays images and gives me the ability to delete > the > > images. > > > > View url == /accou

Re: Redirect to page with query string

2012-08-19 Thread Melvyn Sopacua
On 19-8-2012 3:29, Barry Morrison wrote: > I apologize, I'm new to Django and Python...I've tried every which way I > know how based on what you described, and I can't find success. > > Here is what I'm at right now: > > http://dpaste.org/7JcGT/ > > I get this error: 'DeleteCommunityImages' obje

database query error:Subqueries are not supported (yet)

2013-01-14 Thread jianhui chen
oatField() depth = models.FloatField() normalX = models.FloatField() normalY = models.FloatField() normalZ = models.FloatField() imageItem = models.ForeignKey(ImageItem) Then I create some data and save. Finally I query the database. 1, ps = PixelPosition.objects.all() , no e

Re: Need help with GeoDjango distance query.

2013-02-16 Thread Sanjay Bhangar
On Fri, Feb 15, 2013 at 10:00 PM, mack the finger wrote: > http://stackoverflow.com/questions/14889780/distance-query-within-a-certain-distance-based-on-value-in-joined-table > > Basically I want all objects within a certain distance, AS WELL as within > each object's preferred

<    9   10   11   12   13   14   15   16   17   18   >