Benedict Verheyen schreef:
<snip>
> class ScoreAddManipulator(Score.AddManipulator):
> default = {}
>
> def __init__(self):
> # Construct the fields and set the values in default
> Score.AddManipulator.__init__(self)
> ScoreAddManipulator.default["patient"]=[(patient.id,
> patient.name) for patient in Patient.objects.all()])
> ...
> d = datetime.datetime.now()
> s = d.strftime("%d/%m/%Y")
> ScoreAddManipulator.default["c_date"]=s
With a few cups of coffee, it all goes better, doesn't it ? :)
I added this line to the add manipulator:
self.fields[0] = forms.SelectField(field_name="patient",
is_required=True, choices = patient_choices() )
Where patient_choices is a function:
def patient_choices():
patient_choices = [('','---------')]
for patient in Patient.objects.all_sort_on_room():
room_nr = "-"
if ( patient.room ): room_nr = patient.room.number
to_add = (patient.id, patient.name + ' (' + room_nr + ')')
patient_choices.append(to_add)
return patient_choices
I do the same for the ChangeManipulator but i also have to set the id
to reflect the correct selection.
self.fields[0] = forms.SelectField(field_name="patient",
is_required=True, choices = patient_choices() )
self.default["patient"] = self.default["patient_id"]
This solved the issue for me.
Regards,
Benedict
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---