Closed alexkisielewicz closed 1 year ago
Bug fixed by adding save_m2m method within if statement:
if form.is_valid():
post = form.save(commit=False)
post.author = request.user
content = post.content
post.save()
form.save_m2m()
return redirect('user_account')
Solution found on: https://stackoverflow.com/questions/7083152/is-save-m2m-required-in-the-django-forms-save-method-when-commit-false https://docs.djangoproject.com/en/4.1/topics/forms/modelforms/#the-save-method
Describe the bug When the user sends the form with a new post or edits an existing post draft, the tag field stays empty after saving. The database is not being updated as expected.
To Reproduce Steps to reproduce the behavior:
Expected behavior Tags should be saved in the database upon form submission on the add_post and edit_post pages