I really hope this is not a duplicate: I couldn't find anything but that could just mean I'm not good at searching :)
I have a Django app, and the staff is already using the admin app for... well, administration purposes.
I also created a quick data entry page for a specific model, created substantially by dropping a modelform inside the base template, so that I have:- custom fields
- custom widgets
- javascript client-side validation (server-side validation is of course also present)
- and of course my page layout.
...with minimal effort; I know that the admin page can be customized to obtain all this things, but since I have these needs for one operation (insertion) on one model, this was clearly the winning solution.
The problem arises from the fact that this model has two ForeignKey
s to other models in the app.
select
with the related model instances: is it possible to have in my Form/ModelForm the ability to add an instance of the related model in the same way that the Django admin does by default? Or should I do over the thing using the Django admin?
This is intended for use by the editorial staff, and I really can understand them when they say they don't want to make round trips between two pages.开发者_StackOverflow社区
Well, since the admin is written in Django itself, it is possible to do anything in your own code that you can do in Django.
I think you just need to read the documentation on inline formsets.
精彩评论