views:

17

answers:

0
class Zipcode(models.Model):
    city = models.CharField(max_length=100)
    zipcode = models.CharField(max_length=6)

    class Meta:
        ordering = ('zipcode',)
        verbose_name = 'Zipcode'
        verbose_name_plural = 'Zipcodes'

    def __unicode__(self):
        return self.zipcode + ' ' +self.city

class Area(models.Model):
    name = models.CharField(max_length=100)
    zipcodes = models.ManyToManyField(Zipcode)

    class Meta:
        ordering = ('name',)
        verbose_name = 'Area'
        verbose_name_plural = 'Areas'

    def __unicode__(self):
        return self.name

How can I in "Django Admin", autoselect the area when the "user" select a zipcode??? If it's posible?

Is this a hard one?, I think I should use some javascript?, or is there some Django magic?