Answer the question
In order to leave comments, you need to log in
How to setup related model in django to add unlimited number of objects?
Good afternoon!
I can't figure out how to build the right relationship between two models in django.
There is a model A, it stores general information about the company. Model A has an account field that stores an object of model B that stores information about accounts (mail, names, etc.).
Relations did differently, foreign key and many to many.
The problem is that when creating a new model A in the admin panel, the account field contains a list of all existing objects of model B. And you have to choose among them.
I do not need it. It is necessary that each model A has access only to those related models to which it is assigned. That is, when creating a new model, the account field must be empty.
Why I began to do through relationships:
the first thought that came to me was to inherit from model B so that the account field, model A, has the attributes of model B.
This worked, but there is no scalability. That is, I create one object, save it and can no longer create / add anything to this field.
Is it possible somehow to create multiple objects in one field?
Something like a green plus sign that appears if a model field has a link to another model.
Below is a picture of how I wanted it to be.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question