python - Django template doesn't output values to HTML table cells -


i have following template:

 <table>      <tr>          <th>monday</th>         <th>tuesday</th>         <th>wednesday</th>         <th>thursday</th>         <th>friday</th>         <th>saturday</th>         <th>sunday</th>     </tr>      {% row in table %}     <tr>         {% in week_length %}         <td>{{row.i}}</td>         {% endfor %}     </tr>     {% endfor %} </table> 

and following view:

def calendar(request):     template_name = 'workoutcal/calendar.html'      today_date = timezone.now()     today_year = today_date.year     today_month = today_date.month     today_day = today_date.day      table = maketable(today_date) # creates like: [[none, 1, 2, 3, 4, 5, 6],[7, 8, ...],...,[28, 29, 30, 31, none, none, none]]      template = loader.get_template('workoutcal/calendar.html')      #workout.objects.filter("workouts lie between dates")     context = {         'workout_list': workout.objects.filter(date__year = today_year, date__month = today_month, date__day = today_day),         'table': table, # calendar         'week_length': range(7),     }     return httpresponse(template.render(context, request)) 

when access page (localhost:8000/workoutcal), nothing except table headers output. looks this:

the table

inspecting object

i can't figure out why django not putting output cell. want no output elements of list none, , element content (all strings) in other elements. ideas?

you're iterating on wrong thing. calendar list of lists; should iterate on each row, each column in row. week_length irrelevant.

{% week in table %} <tr>     {% day in week %}     <td>{{ week }}</td>     {% endfor %} </tr> {% endfor %} 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -