How to select related plus one?
Hi,
I have two models A and B:
class A(models.Model):
some_fields
some_fields
number
category
category
class B(models.Model):
models.ForeignKey(A)
some_fields
I need to select all records from A which are present in B and the next number in A in the same category.
for example data in A (first column is id):
( 1, some_fields, 1, 2)
( 2, some_fields, 3, 3)
( 1, some_fields, 1, 2)
( 2, some_fields, 3, 3)
( 3, some_fields, 2, 2)
( 4, some_fields, 3, 2)
( 5, some_fields, 4, 2)
data in B:
( 1, 1)
( 2, 3)
so the queryset should return a 1,3,4 records from A.
I'm completely lost and have no idea how to do that.
I'm completely lost and have no idea how to do that.
I tried to implement that thing via django.db.models.F , but without success.
Could somebody please give me an advice how to implement that?
--
-- wbr,
rush.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home