Queryset returning modelinstances of manytomany relationship?

2010-07-12 Thread Doug Warren
Say I have 2 classes as: class Bar(models.Model): prop = IntegerField() class Foo(models.Model): bar = ManyToManyField(Bar) I want to return a QuerySet containing model instances of bar that match the query: QuerySetOfFoos.objects.filter(bar__prop__gt=0) Is there an easy way to do this?

Re: update least syntax?

2010-07-11 Thread Doug Warren
do. You've > already discovered F which is about as complicated as it gets, bt the > update syntax is pretty much limited to setting a field's value to a > consant. > > Looping over the minimum set of things and calling save on each one if > your only option without resorti

update least syntax?

2010-07-10 Thread Doug Warren
Can Django support an update by setting a field to the least of two args? I have a model that looks like: class Bar maxval = models.FloatField() rate = models.FloatField() class Foo(models.Model): bar = models.ForeignKey(Bar) current = models.FloatField() and i'd like to increas

Debugging Django under wsgi and pydev

2010-07-04 Thread Doug Warren
Is there a way to run a django app that's being served on the local machine via Apache and mod_wsgi using the integrated debugger in wsgi? I did a few google searches but nothing popped out as being the obvious solution, other than a suggestion from google to run apache httpd -x which I'd take as

Arbitrary Properties from code

2010-07-01 Thread Doug Warren
Let's say I have some models that look like: class Emotion(models.Model): mood = CharField(unique=True) class Person(models.Model): emotions = ManyToManyField(Emotion) name = CharField() angry = Emotion(mood='angry') angry.save() sad = Emotion(mood='sad') sad.save() bob = Person(nam