Django how select one photo per gallery in one call to DB?

2015-12-28 Thread piasek piasek
I have two models: Gallery and Photo, Photo has Gallery as FK. Is it possible to return in one call one photo per gallery? I already tried: photos = Photo.objects.filter(active=True) photos.annotate(g=Count('gallery')) unfortunately when I call query I got something like that: GROUP BY

Radio button

2015-12-15 Thread piasek piasek
I would like prepare django form for several entries for one model. Let's assume I have model Photo where I upload and save image. >From model I will takie 10 entries and for each of image I would like generate forms to set title, description, check if photo is active. That part I have it and is

django 2 tables one query?

2013-08-27 Thread piasek piasek
Hi I was wondering is it possible to get information about two tables in one query? I have two models Team (id, name, active, country) and Player (id, first_name, second_name, active, team) where Player.team = ForeignKey(Team) Of course one team may have several players and one player have