python - Can I iterate objects from my Django model over a modified HTMLCalendar()? -


This code will only fetch from one object database, instead it will be repeated in the entire calendar on its applicable date.

cal.py

  to www.wednesday.models Import Event Import Calendar Category EventCal (calendar.HTMLCalendar): Def format day (self, day, workday): if Day == 0: Returns & lt; Td class = "noday" & gt; & Amp; Nbsp; & Lt; / Td> Day outside of # day == int (event.dateDay.day): Return '& lt; Td square = "% s" & gt;% d & lt; / P & gt; & Lt; A href = \ "% s \" target = \ "_blank \" & gt;% s & lt; / A & gt; & Lt; / TD & gt; '% (Self.cssclasses [day of the week], day, event.linkURL, event.restaurant) Other: Return' & lt; Td class = "% s" & gt;% d & lt; / Td> Events for event occurring in events = Event.objects.all () = (CRC): C = EventCol (calendar. SUNDAY)   

to import from .whichsdayday.models Django.shortcuts import .pir file from render_to_response import import * import datetime as DT month = ['', 'jan', 'february', 'march', 'april' 'May', 'Jun', 'Jul', 'Aug', 'September', 'Oct', 'Nov', 'Dec'] now = dt.datetime.now () Mon = now Mahindra DEF Calend (Request): Calorie = Render C. Formats (now.yure, now.mmth) events = event.object.All () Returns Render_to_propons ('Kalsa H19,' 'Calendar': CAL, 'Title': '% s for Wind-Win Wednesday Calendar' % Month [intestine]})

cal.html

  # ... & lt; Div id = 'calendar' & gt; & Lt; Div & gt; & Lt; / Div & gt; {% Block main%} {{calendar | Safe}} {% endblock%} & lt; / Div & gt; & Lt; / Div & gt;    

Most of your questions are questionable.

And, it is printing the Django Tag {{event.restaurant}} instead of the data from the model.

That's because formatday () string "{{event.restaurant}}" returns.

The template renders the string in the rendering template.

The template rendering does not see data, it inserts that the data is more template code. It just includes the data in the template.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -