Just trying to clarify your question a bit...

Are you asking if there is a way in the admin interface that when a
user selects a switch from a drop down box that the port drop down box
will be automatically populated/filtered based on the selection in the
switch drop down?

If this is the case I don't believe that it is currently possible "out
of the box" in the Django admin. Some work was being done to integrate
JQuery into the admin for some Ajaxy stuff, but at the moment I don't
think that very much found it's way in. There are probably a few 3rd
party projects that implement this, but I don't know of any off the
top of my head.

If you already know what switch a user as selected (i.e. they saved it
previously), then you can probaby populate the port list by overriding
the formfield_for_foreign_key method in the AdminModel (see:
http://docs.djangoproject.com/en/1.2/ref/contrib/admin/#modeladmin-methods)

Hope this helps!

Dan Harris
[email protected]

On Jun 8, 10:04 am, onorua <[email protected]> wrote:
> I have
> ====
> class User(models.Model):
>     Switch = models.ForeignKey(Switch, related_name='SwitchUsers')
>     Port = models.ForeignKey(Port)
>
> class Switch(models.Model):
>     Name = models.CharField(max_length=50)
>
> class Port(models.Model):
>     PortNum = models.PositiveIntegerField()
>     Switch = models.ForeignKey(Switch, related_name = "Ports")
> ====
>
> I need when I create User or change User, and choose some Switch to
> have Ports only related to that Switch in Option Box.
>
> How can I acheave it?
> Thank you.

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