On 10/25/06, Christian Joergensen <[EMAIL PROTECTED]> wrote:
> Daniel Roseman wrote:
> >>> Country.objects.all().extra(
> >>> where=['(SELECT COUNT(*) FROM appname_soccerteam WHERE
> >>> appname_soccerteam.country_id = appname_country.id) > 0']
> >>> )
> >> Great idea! I did not think about th
[EMAIL PROTECTED] wrote:
> This is already in the api, no need to write extra sql, try:
>
> c.soccerteam_set.count()
>
> http://www.djangoproject.com/documentation/db_api/#backward
I know of the FOO_set-property, but I need to use it as a filter
condition. As far as my Django experience goes, th
Daniel Roseman wrote:
>>> Country.objects.all().extra(
>>> where=['(SELECT COUNT(*) FROM appname_soccerteam WHERE
>>> appname_soccerteam.country_id = appname_country.id) > 0']
>>> )
>> Great idea! I did not think about the 'extra' method. Works perfectly.
>> Gave me a speedup factor of about 25
Christian Joergensen wrote:
> Jonathan Buchanan wrote:
> > You could use QuerySet's "extra" method to add the custom SQL
> > required, which might be something like the following in this case
> > (you'd need to replace "appname" with the name of the application the
> > models belong to, of course)
This is already in the api, no need to write extra sql, try:
c.soccerteam_set.count()
http://www.djangoproject.com/documentation/db_api/#backward
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" grou
Jonathan Buchanan wrote:
>> To understand the problem, assume I have a model consisting of Country
>> and SoccerTeam.
>>
>> The SoccerTeam has a country = models.ForeignKey(Country).
>>
>> Say, I need to find the countries having one or more related soccer
>> teams. I was not able to come up with a
On 10/24/06, Christian Joergensen <[EMAIL PROTECTED]> wrote:
> Hello
>
> To understand the problem, assume I have a model consisting of Country
> and SoccerTeam.
>
> The SoccerTeam has a country = models.ForeignKey(Country).
>
> Say, I need to find the countries having one or more related soccer
>
7 matches
Mail list logo