Re: One to Many+foreign key Query: best way to build the optimal result

2009-06-25 Thread Sam Walters
Thanks for the help. I think you are on the right track however i could not get this to work. Maybe an example query using cursor.execute would help so you can see what i am trying to do. def sqlAllEventsMenu(): cursor = connection.cursor() cursor.execute(""" SELECT events_event.id, event

Re: One to Many+foreign key Query: best way to build the optimal result

2009-06-18 Thread BenW
I'm not sure I completely understand the problem, but I'll give it a stab: events = Event.objects.filter(start__gte=datetime.today()) locations = Location.objects.filter(location__in=events) results = [ {'start': loc.location.start, 'title': loc.location.title, 'id': loc.location.id, 'state_i

One to Many+foreign key Query: best way to build the optimal result

2009-06-17 Thread Sam Walters
Here is the essentials from my models.py file: class Event (models.Model): contact = models.CharField(max_length=100) email = models.CharField(max_length=100) url = mod