Hello all:

This is my first question posted to this group! I am also a noob, so
please be gentle.

So, my issue is, I have a ModelForm, which looks like this:

class UAssumptionsForm(ModelForm):
    primary_le =
forms.ModelChoiceField(queryset=models.Mortality.objects.none())
    secondary_le =
forms.ModelChoiceField(queryset=models.Mortality.objects.none())
    def __init__(self, *args, **kwargs):
        self.insured = kwargs.pop('insured')
        super(ModelForm, self).__init__(*args, **kwargs)
        morts = self.insured.mortalities.all()
        self.fields['primary_le'].queryset = morts
        self.fields['secondary_le'].queryset = morts
    class Meta:
        model = models.UAssumptions

Now, when I render the form I get two choices for each of the fields I
overrode above. This is expected behavior.

What I want though is for each object to have a descriptive name,
rather than "Mortality object", based on the values of the object
itself, so one might have a value of "Caterpillar" and another might
have a value of "Seychelles".

I'm sure this is a common problem and I apologize in advance. I
searched, but being a noob I'm probably not using the right search
terms.

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

Reply via email to