Re: assigning data based on a comparison between two tables

2010-06-10 Thread Alex Robbins
It is probably better to use candidates.count(), rather than len(candidates). len will cause the whole queryset to be loaded into memory. It doesn't look like you use it later, so that is kind of a waste. Hope that helps, Alex >From django docs: Note: Don't use len() on QuerySets if all you want

Re: assigning data based on a comparison between two tables

2010-06-09 Thread Nick
Just to let you know, this code worked out nicely. I made a few changes to the bottom save function: if len(candidates) > 1: raise Exception candidates.update(incumbent=True) On Jun 8, 6:11 pm, Nick wrote: > Thanks Dan, I'll give it a shot > > On Jun 8, 6:00 pm, Dan Harris wrote: > > > Pe

Re: assigning data based on a comparison between two tables

2010-06-08 Thread Nick
Thanks Dan, I'll give it a shot On Jun 8, 6:00 pm, Dan Harris wrote: > Perhaps not the greatest way of doing things, but simple to code/read: > > class Candidate(models.Model): >    first_name = models.CharField(max_length=30) >    last_name = models.CharField(max_length=30) >    incumbent = mode

Re: assigning data based on a comparison between two tables

2010-06-08 Thread Dan Harris
Perhaps not the greatest way of doing things, but simple to code/read: class Candidate(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) incumbent = models.BooleanField() class HoldsOffice(models.Model): first_name = models.CharFie

assigning data based on a comparison between two tables

2010-06-08 Thread Nick
I have two models. One is a list of candidates that have filed to run for office. The second is a list of people who currently hold office. I'd like to compare the two tables and whenever a match is found between the two (an entry in the candidate table shares the same last_name and first_name wit