Try using a subquery for this:
tableC_QuerySet = models.TableC.objects.filter(
tableC_id__in=models.TableB.objects.filter(table_ID = <some value>).values( <fieldname>)
)
Le lundi 1 décembre 2014 14:07:59 UTC-5, check....@gmail.com a écrit :
-- tableC_QuerySet = models.TableC.objects.filter(
tableC_id__in=models.TableB.objects.filter(
)
Le lundi 1 décembre 2014 14:07:59 UTC-5, check....@gmail.com a écrit :
HelloI am very new to python and Django . I have a basic question :1. I have three database tables : Table A , Table B and Table C2. in my views.py i do :for x in tableB_QuerySet
- tableB_QuerySet = models.TableB.objects.filter(
table_ID = <some value>) - This returns 4 rows from table B
- Then i iterate over tableB_QuerySet
tableC_QuerySet = models.TableC.objects.filter(tableC_id = x.<fieldname>)
- I load the temple : template = loader.get_template(>.html>)
- i use context : context = RequestContext(request,{ 'tableC_QuerySet': tableC_
QuerySet,}) - return HttpResponse(template.render(
context)) 3. In my html template i iterate over tableC_QuerySet and print it in a tableproblem is that in my HTML prints only the last entry of tableC_QuerySet . How do i append all the four entries from table C so that HTML gets all the four entries rather than just the last onePS: I cannot change the DBThanks in advanceAppreciate your help
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e0a1fc01-e8a2-49d3-a087-4614f0086fcc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment