Re: Four Hop, Two Criteria Query
On Thu, May 27, 2010 at 12:22 PM, chr <chris@statesofpop.de> wrote:
On May 27, 11:46 am, Lee Hinde <leehi...@gmail.com> wrote:if i get you right, you could accomplish this by using a model method
> So, if I were to display a list of notes, how would I join those two
> together?
get_weather(self):
weather = Weather.objects.filter(weather_date=self.created, ...
cheers, chr
I did that:
def get_weather(self):
weather = Weather.objects.filter(weather_date=self.target_date,zip_code=self.created_by.store.zip_code)
return weather
and it seems to work. (no errors, I can iterate through weather, in models.py) But when I try to access it in the template:
{% for note in notes %}
<div class="note">
{{note.get_weather}}
is the only thing that will work - it returns the unicode object:
([<Weather: Sunny>])
If I try to get a value from the Weather model {{note.get_weather.condition}} - nothing.
I'm clearly not understanding what's getting returned.
I looked at some other code that uses model methods (django-articles, in this case) and that syntax seems to be what is used.
I'm grateful for anymore pointers.
- Lee
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home