I opened up the django shell and wrote some code that I want to place in my views.py Included in this code is a very simple class. I get errors if I try to run the code, are you not supposed to put classes in views.py?
class CataClass(): it=[] mycat='' def index(request): ilist = items.get_list( order_by=('category','-start_date') ) clist = categorys.get_list( order_by=('category_name',) ) cata=CataClass() at={} for a in ilist: if a.get_category() in clist: if cata.mycat == a.get_category().category_name: cata.it.append(a) else: cata.it=[] cata.mycat=a.get_category().category_name cata.it.append(a) at[cata.mycat]=cata.it return render_to_response('student_update/index', {'ilist': ilist, 'clist': clist, 'at': at,}) The above code makes a dictionary with my categories as keys and my item objects bound to a list as the key values. Hell, Maybe I don't even need this code. I have Items and Categorys in my model. An Item has a foreign key to my Categories. I want my index page to show: <h3>Category Name<h3> <ul><li> {{latest 5 items}} </li></ul> <h3>Category Name</h3> <ul><li> {{latest 5 items}} </li></ul> and so on... --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---