On 03/15/2012 11:22 PM, Murilo Vicentini wrote:
Uhmmm, thank you a lot. That was what I was looking for! Sorry for
wasting your time. One last question, does this double-underscore
notation work at my html template? Because after filtering I will want
to display the information of the
Uhmmm, thank you a lot. That was what I was looking for! Sorry for wasting
your time. One last question, does this double-underscore notation work at
my html template? Because after filtering I will want to display the
information of the different models at one row of my table.
On Friday,
You can certainly use Q objects to query across models, just as you can
in a normal QuerySet, by using the double-underscore notation.
https://docs.djangoproject.com/en/1.3/topics/db/queries/#lookups-that-span-relationships
--
You received this message because you are subscribed to the Google
But if I got it correctly I can use Q objects to make complex filters but
they only apply to one model, what I need is a combination of the models.
And since the search can return more than one (or even zero) objects I
can't use get() to see the related objects.
On Thursday, March 15, 2012
If you don't know which fields your users will be searching on in
advance, you'll have to create Q objects and dynamically build your
query in your view.
https://docs.djangoproject.com/en/1.3/topics/db/queries/#complex-lookups-with-q-objects
--
You received this message because you are
Hey guys, sorry if this is a newbie question, but I'm new at django and I'm
having a real hard time trying to figure out how to solve this. So I have
this model.
class Run(models.Model):
speccpus = models.ForeignKey('Speccpu')
hosts = models.ForeignKey('Host')
Task =
Hi Peter,
Am 2012-01-07 03:40, schrieb Peter of the Norse:
One possibility is to try two excludes.
bad_authors = Authors.objects.exclude(pk__in=SetOfAuthors)
qs = Entry.objects.exclude(authors__in=bad_authors)
This will return all entries that don't have authors in SetOfAuthors. It might
One possibility is to try two excludes.
bad_authors = Authors.objects.exclude(pk__in=SetOfAuthors)
qs = Entry.objects.exclude(authors__in=bad_authors)
This will return all entries that don't have authors in SetOfAuthors. It might
even be easier, if you can skip creating SetOfAuthors in the
could you possibly show the query generated?...
# print qs.query
2011/12/6 Carsten Fuchs
> Hi all,
>
> looking at the example models Author and Entry at
>
Hi all,
looking at the example models Author and Entry at
https://docs.djangoproject.com/en/1.3/topics/db/queries/, I would like
to run a query like this:
SetOfAuthors = Authors.objects.filter(...)
qs = Entry.objects.filter(authors__in=SetOfAuthors)
such that (pseudo-code):
I have got tracks working with the extra() function. I do the
following:
tracks.extra(select={'owned':'SELECT Count(*) FROM shop_track_owners
WHERE track_id=shop_track.id and user_id='+str(user.id)})
This works great for tracks. However, how will I do this when I'm just
passing a queryset of
On Nov 14, 1:01 am, Chris wrote:
> Thanks for your reply.
>
> From reading around it sounds as though I am probably not meant to
> solve this in the template (though this does seem like the easier
> option).
>
> I have figured out that I could solve this through an
Thanks for your reply.
>From reading around it sounds as though I am probably not meant to
solve this in the template (though this does seem like the easier
option).
I have figured out that I could solve this through an SQL statement as
follows:
select *, (select Count(*) FROM shop_track_owners
On 12 Lis, 16:12, Chris wrote:
> Is there a way of getting a model function to access user details so
> that I can do a simple "if track.owned" in the template? Is there a
> better solution to doing it in the view? Is there something I have not
> thought of? What
Hi all,
I am new to Django and I am having a little trouble.
The situation:
I am setting up a music selling website (similar to iTunes) for a uni
project. There are Tracks, Albums and Artists as well as users via
Django auth. A user can own a track. This is accomplished with a many
to many field
I have a model which contains a list of users and a list of groups
that can access the model, e.g,,
readers = models.ManyToManyField(User, blank=True, null=True,)
reader_groups = models.ManyToManyField(Group, blank=True,
null=True,)
where User and Group are the standard django auth
On Mon, Jun 22, 2009 at 1:58 PM, Sean Brant wrote:
>
> This is best explained with an example.
>
> i have a model for Stats
>
> class Stat(models.Model):
>key = models.CharField(max_length=50)
>value = models.TextField()
>pub_date = models.DateTimeField()
>
> so
This is best explained with an example.
i have a model for Stats
class Stat(models.Model):
key = models.CharField(max_length=50)
value = models.TextField()
pub_date = models.DateTimeField()
so if i create a few stat objects lets say these.
stat1 = Stat(key='total_books_sold',
On 6/6/07, Bryan Veloso <[EMAIL PROTECTED]> wrote:
>
> > This will grab _all_ score objects, and sort them by baseball score.
> > If there isn't a baseball score, then 'baseball' will have a value of
> > None, which is still a sortable value.
>
> Alright, so just to be safe, I really shouldn't be
> This will grab _all_ score objects, and sort them by baseball score.
> If there isn't a baseball score, then 'baseball' will have a value of
> None, which is still a sortable value.
Alright, so just to be safe, I really shouldn't be showing the values
for all players, since that risks showing
On 6/6/07, Bryan Veloso <[EMAIL PROTECTED]> wrote:
>
> > Score.objects.order_by('-baseball')
> >
> > will return all the objects in reverse order.
>
> Does this only grab the baseball scores? Or grabs all of them and THEN
> sorts them by score?
> (Just for future reference.)
This will grab _all_
> Score.objects.order_by('-baseball')
>
> will return all the objects in reverse order.
Does this only grab the baseball scores? Or grabs all of them and THEN
sorts them by score?
(Just for future reference.)
> However, it looks like your table is intended to be at least partially
> sparse
On 6/6/07, Bryan Veloso <[EMAIL PROTECTED]> wrote:
>
> Alright, new problem for you guys. Here's an example model in an app
> called "scores", which contains all the scores for a particular
> player:
>
> # Baseball
> baseball= models.PositiveIntegerField('Baseball Skill
> Level',
Alright, new problem for you guys. Here's an example model in an app
called "scores", which contains all the scores for a particular
player:
# Baseball
baseball= models.PositiveIntegerField('Baseball Skill
Level', blank=True, null=True, maxlength=4)
# Bowling
bowling
24 matches
Mail list logo