Wednesday, October 3, 2012

Like a Formset but not...

Hi,

I am looking for a way to do something similar to a formset, but
slightly different.

I have a list of students in a class (class as a school subject, not
class in programming) with attendance record objects having a FK to
both student and class, as well as two fields with choices lists
relating to attendance (present, absent | reasons for absence)

What I want is an uneditable list of students on a page, and next to
each student a RadioSelect widget for each of the fields relating to
attendance.

I successfully created a page with formsets listing all the attendance
records for a class, and excluded the unnecessary fields - but this
means that the student FK field is rendered as a drop down list of all
students - ie, it's editable. (as a side note, each record in the
formset is not followed by a line break, making the output ugly. I
didn't expect that)

This is not the desired outcome.

I have thought about going pure views.py - creating a list of students
from the class object and cobbling together some html to add the two
attendance fields, potentially unlinked to the model itself, to render
the page via a table/divs, but am concerned about how stupidly complex
it could become for quite a simple problem, when taking into account
differing numbers of students, matching student names with the radio
buttons selected and using get_or_create()...

Is this via views.py the best method, or am I missing something obvious?

Cheers
L.

--
...we look at the present day through a rear-view mirror. This is
something Marshall McLuhan said back in the Sixties, when the world
was in the grip of authentic-seeming future narratives. He said, "We
look at the present through a rear-view mirror. We march backwards
into the future."

http://www.warrenellis.com/?p=14314

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate