How to get Create Model on Foreign Key field via the Form

Like in the Backend where a Foreign key field add a dropdown as well as Create Object?

How to get same Create Object ‘plus’ button on the frontend ?

What I get
image

What I want (plus button) or something other way-
image

Note- Other way of doing is also welcomed

The plus is just an icon rendered in the template, wired to a JavaScript function to do whatever you need that function to perform.

If you’d like to see a real-life example of this, you can read the source code of the Django admin views to see how they build these pages. (There’s some JavaScript they use to create the pop-up in response to a click on the plus sign. You can look at the JavaScript in your browser using your browser’s developer tools - or at least use that to find where it’s being loaded from to look at the original source.)

1 Like