0

I two model classes

class Product(models.Model)
    name = ...

class Part(models.Model)
    product = models.ForeignKey(Product, on_delete= models.CASCADE,default=1)

In my database I already have populated a number of parts.

Is there a way to change Admin to allow a drop down/select of parts for the product I'm looking at,

e.g I want to assign a foreign key relationship of parts A, B, C, F to the Product I'm looking at the admin page for Proudct X.

I have seen the inline option, but I don't want to add new parts, I just want to be able to associate the parts with the product I'm looking at

Thanks in advance for the help!

Kenny O.
  • 73
  • 1
  • 6
  • 1
    Althoug not an answer, why do you set `default=1` in the `ForeignKey`? – Willem Van Onsem Sep 12 '18 at 17:07
  • Oh, I kinda paired down the class for brevity of example. Honestly, it was just a remnant of when I built the models initially. I think I had it because i added the field later, and django did that thing where when running manage.py migrate it said "set a default" to continue, so I just added one, and the I made the Product 1 a "test product" – Kenny O. Sep 12 '18 at 18:42

0 Answers0