barseghyanartur / django-fobi

Form generator/builder application for Django done right: customisable, modular, user- and developer- friendly.
https://pypi.python.org/pypi/django-fobi
484 stars 112 forks source link

[Question] Is is it possible to create a form that automatically creates a Django Model instance? #235

Closed gabn88 closed 4 years ago

gabn88 commented 4 years ago

The form building part of this app looks great. But my user wants to create a model instance with the form data.

Let's say the model instance is a Book and it has Chapters and it is part of a Library.

I would like the user to be able to create a Book with Chapters with a self-generated form (there are more fields on the Book, but we want to show only some), but only within the Library that they belong to (where Library is a ForeignKey on Book). Is this possible?

Of course this user can now also create Books in the Library already, but this user wants to create a BookForm that is accessible publicily, so anonymous users can create a Book by a Book Intake Form with just a few Chapters in it in their library with a hidden form.

Or maybe: is it possible to do a POST with contenttype JSON to an API endpoint with authentication after submitting the form?

Any help is appreciated.

barseghyanartur commented 4 years ago

Everything is possible. What you describe looks like some custom form callback. See the documentation for the details.