K
K
k0r0g2021-04-29 17:23:20
Django
k0r0g, 2021-04-29 17:23:20

How in the admin panel to make adding a record a choice from another table?

Hello.
We simulate the situation: there is a website that sells any goods. On the main page, (actual products) / (products that the site owner wants to display on the main page) / (* any other principle by which products are selected on the main page *) are displayed. But the point is that the main page will display several of the existing products.
At this point, I thought, "How to make it convenient for the owner?". After all, he, most likely, will want to change the products that are displayed on the main page. It is clear that this will happen through the admin panel.
So, there are 2 tables: "products" and "productsOnHome". How to add a record to the products is clear: enter the field values. And to add products to the table on the main page, I want the owner to select from the drop-down menu in the admin panel, in which there will be (id) / (any other understandable field from the "products" table).
So, the question is: can this be implemented at all, or should I come up with another way that will be less convenient, but feasible?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
_
_, 2021-04-30
@k0r0g

So make a one-to-one relationship products-productsOnHome and let each productOnHome refer to some product, and the data itself will always be taken from "products".
In the admin panel, when you start the goodsOn the main django itself will offer to select an object for communication from the "goods". If there are many products - use raw_id in the admin panel.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question