ForeignKey as dropdown list, get user's choice

81 views
Skip to first unread message

mapapage

unread,
Jul 24, 2012, 5:36:40 AM7/24/12
to django...@googlegroups.com
Hello!
I have a form including a field: veh_id1 = models.ForeignKey(Vehicles)) that is being rendered on the template as dropdown list.
Now I want according to the user's choice in that list some other fields of my form to be auto-completed and displayed on the template before the form submission.
I guess that I should use ajax for that. But I really don't know how I will access that user's choice in veh_id1 since it's not rendered as a classic html select and I don't have id for each choice etc. Sry if my question is dump but I'm new to all that and now I'm stuck.

Dmitry Zimnukhov

unread,
Jul 24, 2012, 10:02:03 AM7/24/12
to django...@googlegroups.com
First you say that the field "is being rendered on the template as
dropdown list", and then "it's not rendered as a classic html select"
How is it rendered? Isn't html select a drop-down list?
By the way models.ForeignKey is a model field, not a form field. How
is your form defined?

2012/7/24 mapapage <mapa...@gmail.com>:
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/F6XpJXQ70UoJ.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
Reply all
Reply to author
Forward
0 new messages