Hello to everyone, I'm quite new so please go easy on me. I already searched on the mailing list but couldn't find a good answer for my problem. I am writing a project for a website where i retrieve events from a database, together with them I need, on the same page, to show a list of banners, taken from an other model other than the one regarding the events. Here is the code:
------------------------------------------------- class CampagnaPubblicitaria(models.Model): ... sponsor= models.ForeignKey(Sponsor) def in_campagna(self): #determina il periodo della campagna pubblicitaria oggi= datetime.toordinal(TODAY) data_inizio_campagna_ord= datetime.toordinal(self.data_inizio_campagna) if data_inizio_campagna_ord<= oggi <= (data_inizio_campagna_ord+ self.durata_campagna): return True else: return False ... class Sponsor(models.Model): banner= models.ForeignKey(Banner) ... ------------------------------------------------- Now, I am using django own generic date based views and i am trying to pass as an extra_context value this: banner_list= Banner.objects.filter(sponsor__campagnapubblicitaria__in_campagna= True).order_by('?')[:6] evento_index_info_dict= { 'queryset': Evento.objects.all(), 'date_field': 'data_di_inserimento', 'extra_context': {'banner_list': banner_list} } But when i try to have a look at the page, i get this error: --- TypeError at / Cannot resolve keyword 'in_campagna' into field --- Is that because the QuerySet doesn't actually evaluate the value of in_campagna for every record of the database? Is there any other way to do the same job, other than writing a huge filter? ^^' And, am I wrong i pass the extra_context in a "urls" context rather than a "view" context? Is there any other way to write extra_context for the template other than write it directly on the urls.py code? Thanks in advance if anyone will have the patience to understand what i wrote and the patience to reply me. Regards, David -- Brokenseal di Callegari Davide Le informazioni contenute in questo messaggio di posta elettronica sono riservate e confidenziali e ne e' vietata la diffusione in qualunque modo eseguita. Qualora Lei non fosse la persona a cui il presente messaggio e' destinato, La invitiamo ad eliminarlo e a non utilizzare in alcun caso il suo contenuto, dandone gentilmente comunicazione al mittente. The information contained in this e-mail and any attachments is confidential and may well also be legally privileged. If you are not among the named recipients, please notify the sender immediately by reply e-mail and then delete this message from your system, do not use the contents for any purpose whatsoever nor disclose them to anyone else. Rif. D.L. 196/2003. --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---