Dear all,

say I have a model "boat" with a radio field which let me choose
between "sailing boat" and "motor boat".

##################################################

class Boat(models.Model):
    name = models.CharField(max_length=30)
    TYPE = (
        ('S', 'Sailing Boat'),
        ('M', 'Motor Boat'),
    )
    type = models.CharField(max_length=1, choices=TYPE, default='S')
    sailmaker = models.ForeignKey(Sailmaker,blank=True,null=True)
    motor = models.ForeignKey(Motor,blank=True,null=True)

class BoatAdmin(admin.ModelAdmin):
    radio_fields = {'type': admin.VERTICAL}

##################################################

This is the behaviour I would like to have for my admin: when I select
the "Sailing boat" radio button, the field sailmaker is shown and the
field motor is hidden (to fix ideas, just suppose that sailing boats
don't have any motors). Viceversa, when I select the "Motor boat"
radio button, motor is shown and sailmaker is hidden.

I think this brief javascript snippet could come in handy:

##################################################

<script language=javascript>
function hide() {
document.getElementById('myid').style.display = 'none'
}

function show() {
document.getElementById('myid').style.display = 'block'
}
</script>

##################################################

The point is I don't know:

- how to customize the snippet to my needs
- where to put it (in my change_form.html?)
- how make the radio field to call the js

Any help is really appreciated.

Cheers,

-- 
Fabio Natali

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to