Django model model: is it possible to add a related model?

I really hope this is not a duplicate: I could not find anything, but it could mean that I can not search :)

I have a Django app, and employees are already using the admin app for ... well, administration purposes.
I also created a quick data record page for a specific model, created essentially by dropping the model of the model inside the base template, so I have:

  • custom fields
  • custom widgets
  • Javascript client side validation (of course, server side validation is also present)
  • and of course the page layout.

... with minimal effort; I know that the administration page can be configured to get all these things, but since I have these needs for one operation (insertion) on the same model, this was clearly a winning solution.

The problem arises because this model has two ForeignKeyfor other application models.
The model render does this by default with the help of selectthe corresponding model instances: is it possible to have in my form / ModelForm the ability to add an instance of the associated model in the same way as the default Django Administrator? Or should I do this with a Django admin?

This is intended for use by the editors, and I really can understand them when they say that they don’t want to make round trips between two pages.

+3
1

, Django, - , Django.

, .

+2

Source: https://habr.com/ru/post/1731549/


All Articles