I'd cycle in the template through a list of exam periods, printing a table
for each cycle.
You have to pass the list of exam periods in the context of your view.

Try and let me know.

Regards,
Leo


Leonardo Giordani
Author of The Digital Cat <http://lgiordani.github.com>
My profile on About.me <http://about.me/leonardo.giordani> - My GitHub
page<https://github.com/lgiordani>- My Coderwall
profile <https://coderwall.com/lgiordani>


2013/10/2 +Emmanuel <eluse...@gmail.com>

> Am working on a Django project that retrieves a student's details from the
> database, filters them based on the 'period of examination' (this is
> implemented as a python list in a custom filter) and displays the output.
>
> *Here is my custom filter:*
>
> @register.filter
> def periodofexamination(periodofexam):
>     periodofexam = ['DECEMBER 2011', 'MAY 2011', 'DECEMBER 2010']
>     for period in periodofexam:
>         return period
>
> *The template for displaying the output:*
>
> {% extends 'base.html' %}
> {% load results_extras %}
> {% block title %}My Results{% endblock %}
>
> {% block content %}
> <h3> My Tentative Examination Results</h3>
> <div class="alert alert-info">The results displayed below are tentative
> and for information purposes only.</div>
>
>     <table class='table table-striped table-bordered'>
>     <thead><th>Course Code</th><th>Course Name</th><th>Course
> Work</th><th>Exam</th><th>Grade</th><th>GPA</th><th>Year</th><th>Exam
> Period</th></thead>
> {% for query in queryset %}
>
>     <tr><td>{{
> query.coursecode}}</td><td>{{query.coursename}}</td><td>{{query.coursework}}</td><td>{{query.exam}}</td><td>{{query.exam|grade}}</td><td>{{query.exam|gpa}}</td><td>{{query.academicyear}}</td><td>{{query.examperiod}}</td></tr>
>
> {% endfor %}
> </table>
> {% endblock %}
>
> *The output:*
> See the attached file (screenshot.png)
>
> *The challenge:*
> I would like to be able have the student results for a given exam period
> to appear each in their own table, for instance, all the results for exam
> period 'December 2011' should be in one table, all the results for exam
> period 'December 2010' should be in a different table. Currently, all the
> results appear in one table.
> How do I implement this using a custom filter?
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/bed2d4a9-2439-41bd-81a0-be2c4964ca6b%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEhE%2BO%3DsKK-mb4nMTBf493e%2BJ2483i3Qeuh%3D8qJ8Ckur1qJ%2B%2Bg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to