On Feb 10, 2:25 pm, Almost George <almostgeo...@almostexciting.com>
wrote:
> On Feb 10, 1:30 am, Daniel Roseman <roseman.dan...@googlemail.com>
> wrote:

> That doesn't seem to work. Here's my manage.py shell session, which
> appears as I expected it to: (hopefully email clients/google won't
> screw up the quoting, otherwise seehttp://dpaste.com/118932/)
>
> >>> from xmx.models import Band
> >>> b = Band.objects.get(name__startswith='r')
> >>> b
> <Band: rod>
> >>> b.get_upcoming_events
>
> <bound method Band.get_upcoming_events of <Band: rod>>>>> 
> b.get_upcoming_events()
>
> Traceback (most recent call last):
>   File "<console>", line 1, in <module>
>   File "/xxxx/xxxxx/django_projects/../xmx/models.py", line 39, in
> get_upcoming_events
>     return self.event.eventoccurrence_set.filter
> (start__gte=datetime.today())
> AttributeError: 'Band' object has no attribute 'event'
>
> - Any other suggestions?

Aah, sorry, didn't read the models properly. Try this:

events = EventOccurrence.objects.filter(
    start__gte=datetime.today(),
    event__bands=self
)

Not sure if that will work, but I often find that it helps to turn a
query around so you start with the model you want, and filter it back
to include the related object you have, if you see what I mean.
--
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-users@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