Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have two models basically the category and the product (having a foreign field related to the category). Several categories have been created through the admin page and next would be creating the products under each category.

I would like to know in Django Admin, if there is a way I could click on the individual category and create a product directly under the category I selected.

Note that I understand I can create a product and select the category directy, but I just want to know if I can do it from the category side.

Thank you.

# my models
class Category(models.Model):
    code = models.CharField(max_length=45, unique=True)
    name = models.CharField(max_length=45)

class Product(models.Model):
    part_number = models.CharField(max_length=45, unique=True)
    category = models.ForeignKey(Category, on_delete=models.RESTRICT)
    brand = models.CharField(max_length=45, blank=True, null=True)
    specification = models.CharField(max_length=45)

Currently I have


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
577 views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...