When I include this in my page, the page blows up with an internal
error (no explanation, just internal error):

{% for sn in history.get_events %}
{% if sn.event %}
{{ sn.event}}
{% endif %}
{% endfor %}

Here is history.get_events:

def get_events(self):
        from mysite.serial_numbers.models import Serial_Number
        serial_numbers = []
        for serial_number in Serial_Number.objects.all():
            if serial_number.year.id == self.id:
                serial_numbers.append(serial_number)
           return serial_numbers

Obviously, history has a year field, as does serial_number. Certain
events are associated with certain serial numbers, and I'm attempting
to capture the events that happened in the appropriate year.
So, if serial number 1 has year 2006 and event x and serial number 2
has year 2006 and event y, then attach x and y to history year 2006, if
that makes sense.

As I'm explaining it, I'm wondering if the problem is that for every
year (and there's a bunch of them) I'm calling get_events in the
template, which is then in turn having to loop through all the SNs
(there's a bunch of them, too), and the whole thing is failing because
it's just too darn inefficient.

So, am suggestions on a better way to do it? I thought about running
getEvents when I save the year, but then if more events get added they
wouldn't be attached.

So all suggestions are welcomed.


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to