I’m building a web application (in Django) that will accept a search criteria and display a report – once the user is satisfied with the results, save both the criteria and a reference to these objects back to the database.
The problem I’m having is finding an elegant solution for having 2 forms:
- Display (GET) the results of their criteria.
- Enter in some descriptions, and save (POST) everything back to the database.
I’m leaning towards AJAX for the GET stuff and a POST for the save, but I wanted to make sure there wasn’t a more elegant solution first.
Before implementing ajax, i’ll try to make the forms work with javascript disabled. The 2 forms can point to the same view.
For routing the action, You can use
<button type="submit">tags withnamevalueattributes filled, instead of<input type="submit">.The 2 forms template
The not so ugly one form template
Then, catch the “action” into your view, like this code (not tested)
Then you can some ajax