I posted this on Djangu Users, but Django Developers may be a better
place.

I have a model with the following (exerpt):

class Team(meta.Model):
    name = meta.CharField(maxlength=200)
    venue = meta.CharField(maxlength=200)
    division = meta.ForeignKey(Division)
    # snip snip snip

class Division(meta.Model):
    name = meta.CharField(maxlength=40)
    conference = meta.ForeignKey(Conference)
    # snip snip snip

I am using the update_object generic view to present the update form
for an existing Team. It has {{ form.name }}, {{ form.venue }}, and {{
form.division }} in the form template. The view correctly creates a
"select" for the division, but the "selected" value is the first one
("---------") instead of the correct one already set (and validated in
the DB) for the team's division.

Is there some attribute/parameter I can add to {{ form.division }} to
make it correctly select the existing value? It seems this should be
the default, but I couldn't find a generic views example which
contained a SELECT (for a hard-coded set of choices or for a foreign
key situation). If one exists and I just didn't find it, I apologize.

Thanks for any light which can be shed.

H.B.

Reply via email to