Tuesday, January 26, 2010

Re: is there a way to cascade foreign keys?

thanks for the replies.

I've spotted a few ajax/django uts, in particular this one that is
quite appropriate
http://www.nerdydork.com/dynamic-filtered-drop-down-choice-fields-with-django.html

I've tried to follow it, but i must be missing something cos it
doesn't work on my testbed.

i should add that the reason the post was named thus was because
originally my model looked like ...

class VehMake(models.Model):
name = models.CharField(max_length=30)

class VehModel(models.Model):
name = models.CharField(max_length=30)
vehmake = models.ForeignKey(VehMake)

class VehYear(models.Model):
year = models.CharField(max_length=12)
vehmodel = models.ForeignKey(VehModel)

class VehTrim(models.Model):
trim = models.CharField(max_length=30)
vehYear = models.ForeignKey(VehYear)

however im now persuing a different model which is the above
collapsed.
class Vehicle(models.Model):
vehmake = models.CharField(max_length=30)
vehmodel = models.CharField(max_length=30)
vehyear = models.CharField(max_length=12)
vehtrim = models.CharField(max_length=30)

Im pretty sure i've worked out how to create a view and post back to
that view, working out from the post request which field was just
selected and then creating a new dictonary from that selection and
offering up the next populated dropdown.

--
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