0👍
✅
Thank you @Sunderam Dubey for helping. I found the answer to my question. The problem was in the create method, I rewrote it a little differently (code below) and I was able to display the error text:
def create(request):
form = TrainForm()
if request.method == "POST":
form = TrainForm(request.POST)
if form.is_valid():
form.save()
return redirect('/')
return render(request, "main/create.html", {"form": form})
1👍
Try to use the looping syntax of showing errors so instead of only {{field.errors}}
use it as following:
{% for error in field.errors %}
{{ error }}
{% endfor %}
- [Answered ]-How can I order a Django query against a custom list of values?
- [Answered ]-Django + Bootstrap + nav-tabs are wrongly displayed
- [Answered ]-Creating parent model that all models will inherit from in Django
Source:stackexchange.com