0

Hi I have 3 models in my django. Product, Client, and Order.

Class Client(models.Model):
 name = ...
 ....

Class Product(models.Model):
 name = ...
 client = models.ForeignKey(Client)
 .....

Class Order(models.Model):
 qty = ...
 created = ...
 customer_name = ...
 ...
 ...
 client = models.ForeignKey(Client)
 product = models.ForeignKey(Product)

admin.py

    class OrderAdmin(admin.ModelAdmin):
        pass

    admin.site.register(Order, OrderAdmin)

the flow of my project is that, I have so many Clients and each of them have so many products. So when there is an Order, I specify the Clients and the product of the order.

my problem is this, in my Admin page, when I add an Order, select a particular client and when I scroll down the Product field, it will show all the lists of products.

my question is that, is it possible that in admin page,in adding an Order when I scroll the Product, it will show only the Product lists of the client that I have selected? and how to do it?

gadss
  • 21,687
  • 41
  • 104
  • 154

1 Answers1

0

Yes, its possible and fairly well documented. Here is the official documentation: custom validation. This might also help: stackoverflow link

Community
  • 1
  • 1
jörg
  • 3,221
  • 3
  • 20
  • 12