1👍
✅
There is, of course, a way to only use some fields in a modelform: as fully documented in Using a subset of fields on the form, you can use the fields
or exclude
attributes in the form’s Meta class.
However you’ll still need, as szaman points out, to pass the POST data to the form and check for validity, and in addition you’ll need to pass in the instance
paramater as you’re updating an existing instance.
0👍
What I see is that you get object from database and when form is submitted than just saving the object, but you don’t update any field so you cannot see changes in db. Try to do:
if request.method == "POST":
form = MyForm(request.POST)
logging.info("form.is_valid() %s" % form.is_valid())
if form.is_valid():
item_to_edit.name = form.cleaned_data['name']
item_to_edit.save()
...
- [Answer]-Django web application and ways to flush cached media
- [Answer]-Bootstrap and django keep button and input on same line
- [Answer]-Will Flat Design cause slow loading of page
- [Answer]-ImportError: No module named pyorbited.simple while running django-orbited
- [Answer]-Creating a post/comment ability in Django
Source:stackexchange.com