views:

272

answers:

1

Hi guys, there is something that i would like do.

i have 4 class:

class delivery(models.Model):          
      name= models.CharField(max_length=100)
      date_join= models.DateField()
      ....

class Town(models.Model):
      delivery_guy = models.ForeignKey(delivery)
      name = models.CharField(max_length=100)
      ....

class message(models.Model):
      title= models.CharField(max_length=100)
      notes = models.CharField(max_length=200)
      date= models.DateField()
      ....

class childs_of_message(models.Model):
      message =models.ForeignKey(message)
      delivery_guy = models.ForeignKey(delivery)
      direction = models.ForeignKey(delivery)
      people_name= models.CharField(max_length=100)
      date= models.DateField()
      ....

I dont know how ill say this, my English is poor, the Town have a delivery_guy, the Message have a Town and the Childs_of_message have a Message and have a Delivery.

In Inlines mode im showing Message like "parent" and Childs_of_message like "child - inlines-", in my childs_of_message, i would like in the select of delivery_guys show the default delivery guy from the Town (if the town have a delivery ill show this delivery selected in the SELECT form in childs_of_message inline mode)

or

how ill make and ModelChoiceField(queryset....) in my inline form admin?

Thanks :)

A: 

since the admin interface in django is only for trusted users i'm not sure that you are able to change the queryset of a modelchoicefield. it's always going to show all the model objects that apply.

what you want to do is build your own interface with a django form. then you can use initial for the form fields based on other information that you have when the form is initialized.

Brandon H
I'm 98% sure you *can* change the queryset. You can create an admin form to use instead which pretty much gives you full control...
Mark