On May 27, 10:03 am, Lee Hinde <leehi...@gmail.com> wrote:
> Hi;
>
> I have this model design:
>
> http://dpaste.com/hold/199818/
>
> class Weather(models.Model):
>     weather_date = models.DateField(auto_now_add=True,db_index=True)
>     zip_code = models.CharField(max_length=20,db_index=True )
>     icon_data = models.CharField(max_length=80)
>
> class Store(models.Model):
>     name = models.CharField(max_length=50,)
>     zip_code = models.CharField(max_length=20)
>
> class UserProfile(models.Model):
>     store = models.ForeignKey(Store)
>     user = models.OneToOneField(User, unique=True)
>     role = models.CharField(max_length=80,db_index=True,
> choices=ROLE_CHOICES)
>
> class Note(models.Model):
>     created_by = models.ForeignKey(UserProfile,editable=False)
>     created = models.DateField(auto_now_add=True)
>
> For a given Note, I'd like to know the weather on the day and at the
> location for the user who created the note. (the weather data is entered via
> a custom management command.)

<snip>

> I can't think of a way to express this in the ORM. This seems like an
> obvious case for "select()", but  I haven't had any luck with the various
> combinations of pure select and the new paramater options.
>
> Any help would be appreciated.
>
>  - Lee

Does this not work?

note=Note.objects.get(whatever)
weather=Weather.objects.filter(
    weather_date=note.created,
    zip_code=note.created_by__store__zip_code
)
--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to