Django - ValidationError does not display
I recently tried the forms validations and faced an issue with ValidationError().
The form error does not appear in my website when I submit the form.
Here is the code:
forms.py
class ArticleForm(forms.ModelForm):
def clean_titre(self):
titre = self.cleaned_data['titre']
if len(titre) < 5:
raise ValidationError('myError')
return titre
form = ArticleForm()
template.html
<div class="form-group">TITRE
{{ form.titre.errors }}
{{ form.titre }}
</div>
views.py
def AddArticle(request):
form = ArticleForm(request.POST, request.FILES)
if form.is_valid():
save_it = form.save(commit=False)
save_it.user = request.user
save_it.save()
form.save_m2m()
return HttpResponseRedirect('/')
What did I do wrong?
--- EDIT ---
Full template.html
<form class="form" action="{% url "article.views.AddArticle" %}" method="post" enctype='multipart/form-data'>
{% csrf_token %}
<div class="form-group">TITRE
{{ form.titre.errors }}
{{ form.titre }}
</div>
<div class="form-group">SUMMARY
{{ form.media }}
{{ form.summary.errors }}
{{ form.summary }}
</div>
<div class="form-group">CONTENU
{{ form.media }}
{{ form.contenu.errors }}
{{ form.contenu }}
</div>
<div class="form-group">
{{ form.image.errors }}
{{ form.image }}
</div>
<div class="form-group">TAGS
{{ form.tags.errors }}
{{ form.tags }}
</div>
<input type="submit" class="btn btn-default" value="Submit" autocomplete="off" autocorrect="off" />
</form>
I'll post the full forms.py too, it may help.
forms.py
class ArticleForm(forms.ModelForm):
def clean_titre(self):
titre = self.cleaned_data['titre']
if len(titre) < 5:
raise ValidationError('myError')
return titre
class Meta:
model = Article
exclude = ['date', 'rating', 'user']
widgets={
"titre":forms.TextInput(attrs={'placeholder':'Le titre', 'class':'form-control'}),
"contenu":forms.Textarea(attrs={'placeholder':'Le Contenu de votre message', 'class':'form-control'}),
"image":forms.FileInput(attrs={'placeholder':'Votre Image', 'id':'uploadBtn'}),
"tags":TagWidget(attrs={'placeholder':'Vos Tags', 'class':'form-control'}),
}
form = ArticleForm()
python django
add a comment |
I recently tried the forms validations and faced an issue with ValidationError().
The form error does not appear in my website when I submit the form.
Here is the code:
forms.py
class ArticleForm(forms.ModelForm):
def clean_titre(self):
titre = self.cleaned_data['titre']
if len(titre) < 5:
raise ValidationError('myError')
return titre
form = ArticleForm()
template.html
<div class="form-group">TITRE
{{ form.titre.errors }}
{{ form.titre }}
</div>
views.py
def AddArticle(request):
form = ArticleForm(request.POST, request.FILES)
if form.is_valid():
save_it = form.save(commit=False)
save_it.user = request.user
save_it.save()
form.save_m2m()
return HttpResponseRedirect('/')
What did I do wrong?
--- EDIT ---
Full template.html
<form class="form" action="{% url "article.views.AddArticle" %}" method="post" enctype='multipart/form-data'>
{% csrf_token %}
<div class="form-group">TITRE
{{ form.titre.errors }}
{{ form.titre }}
</div>
<div class="form-group">SUMMARY
{{ form.media }}
{{ form.summary.errors }}
{{ form.summary }}
</div>
<div class="form-group">CONTENU
{{ form.media }}
{{ form.contenu.errors }}
{{ form.contenu }}
</div>
<div class="form-group">
{{ form.image.errors }}
{{ form.image }}
</div>
<div class="form-group">TAGS
{{ form.tags.errors }}
{{ form.tags }}
</div>
<input type="submit" class="btn btn-default" value="Submit" autocomplete="off" autocorrect="off" />
</form>
I'll post the full forms.py too, it may help.
forms.py
class ArticleForm(forms.ModelForm):
def clean_titre(self):
titre = self.cleaned_data['titre']
if len(titre) < 5:
raise ValidationError('myError')
return titre
class Meta:
model = Article
exclude = ['date', 'rating', 'user']
widgets={
"titre":forms.TextInput(attrs={'placeholder':'Le titre', 'class':'form-control'}),
"contenu":forms.Textarea(attrs={'placeholder':'Le Contenu de votre message', 'class':'form-control'}),
"image":forms.FileInput(attrs={'placeholder':'Votre Image', 'id':'uploadBtn'}),
"tags":TagWidget(attrs={'placeholder':'Vos Tags', 'class':'form-control'}),
}
form = ArticleForm()
python django
Where's the rest of that view? What happens if is_valid is not True? Or if it's not a POST?
– Daniel Roseman
Jul 25 '15 at 19:46
I don't have the rest, I didn't know I needed one, what should I write it the "else:"?
– Nuri Katsuki
Jul 25 '15 at 19:50
In that case you would definitely get an exception, because every view must return a response. If your form is not valid but you are not getting an exception, you cannot be using this view at all.
– Daniel Roseman
Jul 25 '15 at 19:52
add a comment |
I recently tried the forms validations and faced an issue with ValidationError().
The form error does not appear in my website when I submit the form.
Here is the code:
forms.py
class ArticleForm(forms.ModelForm):
def clean_titre(self):
titre = self.cleaned_data['titre']
if len(titre) < 5:
raise ValidationError('myError')
return titre
form = ArticleForm()
template.html
<div class="form-group">TITRE
{{ form.titre.errors }}
{{ form.titre }}
</div>
views.py
def AddArticle(request):
form = ArticleForm(request.POST, request.FILES)
if form.is_valid():
save_it = form.save(commit=False)
save_it.user = request.user
save_it.save()
form.save_m2m()
return HttpResponseRedirect('/')
What did I do wrong?
--- EDIT ---
Full template.html
<form class="form" action="{% url "article.views.AddArticle" %}" method="post" enctype='multipart/form-data'>
{% csrf_token %}
<div class="form-group">TITRE
{{ form.titre.errors }}
{{ form.titre }}
</div>
<div class="form-group">SUMMARY
{{ form.media }}
{{ form.summary.errors }}
{{ form.summary }}
</div>
<div class="form-group">CONTENU
{{ form.media }}
{{ form.contenu.errors }}
{{ form.contenu }}
</div>
<div class="form-group">
{{ form.image.errors }}
{{ form.image }}
</div>
<div class="form-group">TAGS
{{ form.tags.errors }}
{{ form.tags }}
</div>
<input type="submit" class="btn btn-default" value="Submit" autocomplete="off" autocorrect="off" />
</form>
I'll post the full forms.py too, it may help.
forms.py
class ArticleForm(forms.ModelForm):
def clean_titre(self):
titre = self.cleaned_data['titre']
if len(titre) < 5:
raise ValidationError('myError')
return titre
class Meta:
model = Article
exclude = ['date', 'rating', 'user']
widgets={
"titre":forms.TextInput(attrs={'placeholder':'Le titre', 'class':'form-control'}),
"contenu":forms.Textarea(attrs={'placeholder':'Le Contenu de votre message', 'class':'form-control'}),
"image":forms.FileInput(attrs={'placeholder':'Votre Image', 'id':'uploadBtn'}),
"tags":TagWidget(attrs={'placeholder':'Vos Tags', 'class':'form-control'}),
}
form = ArticleForm()
python django
I recently tried the forms validations and faced an issue with ValidationError().
The form error does not appear in my website when I submit the form.
Here is the code:
forms.py
class ArticleForm(forms.ModelForm):
def clean_titre(self):
titre = self.cleaned_data['titre']
if len(titre) < 5:
raise ValidationError('myError')
return titre
form = ArticleForm()
template.html
<div class="form-group">TITRE
{{ form.titre.errors }}
{{ form.titre }}
</div>
views.py
def AddArticle(request):
form = ArticleForm(request.POST, request.FILES)
if form.is_valid():
save_it = form.save(commit=False)
save_it.user = request.user
save_it.save()
form.save_m2m()
return HttpResponseRedirect('/')
What did I do wrong?
--- EDIT ---
Full template.html
<form class="form" action="{% url "article.views.AddArticle" %}" method="post" enctype='multipart/form-data'>
{% csrf_token %}
<div class="form-group">TITRE
{{ form.titre.errors }}
{{ form.titre }}
</div>
<div class="form-group">SUMMARY
{{ form.media }}
{{ form.summary.errors }}
{{ form.summary }}
</div>
<div class="form-group">CONTENU
{{ form.media }}
{{ form.contenu.errors }}
{{ form.contenu }}
</div>
<div class="form-group">
{{ form.image.errors }}
{{ form.image }}
</div>
<div class="form-group">TAGS
{{ form.tags.errors }}
{{ form.tags }}
</div>
<input type="submit" class="btn btn-default" value="Submit" autocomplete="off" autocorrect="off" />
</form>
I'll post the full forms.py too, it may help.
forms.py
class ArticleForm(forms.ModelForm):
def clean_titre(self):
titre = self.cleaned_data['titre']
if len(titre) < 5:
raise ValidationError('myError')
return titre
class Meta:
model = Article
exclude = ['date', 'rating', 'user']
widgets={
"titre":forms.TextInput(attrs={'placeholder':'Le titre', 'class':'form-control'}),
"contenu":forms.Textarea(attrs={'placeholder':'Le Contenu de votre message', 'class':'form-control'}),
"image":forms.FileInput(attrs={'placeholder':'Votre Image', 'id':'uploadBtn'}),
"tags":TagWidget(attrs={'placeholder':'Vos Tags', 'class':'form-control'}),
}
form = ArticleForm()
python django
python django
edited Jul 25 '15 at 21:25
Nuri Katsuki
asked Jul 25 '15 at 19:41
Nuri KatsukiNuri Katsuki
1,96762856
1,96762856
Where's the rest of that view? What happens if is_valid is not True? Or if it's not a POST?
– Daniel Roseman
Jul 25 '15 at 19:46
I don't have the rest, I didn't know I needed one, what should I write it the "else:"?
– Nuri Katsuki
Jul 25 '15 at 19:50
In that case you would definitely get an exception, because every view must return a response. If your form is not valid but you are not getting an exception, you cannot be using this view at all.
– Daniel Roseman
Jul 25 '15 at 19:52
add a comment |
Where's the rest of that view? What happens if is_valid is not True? Or if it's not a POST?
– Daniel Roseman
Jul 25 '15 at 19:46
I don't have the rest, I didn't know I needed one, what should I write it the "else:"?
– Nuri Katsuki
Jul 25 '15 at 19:50
In that case you would definitely get an exception, because every view must return a response. If your form is not valid but you are not getting an exception, you cannot be using this view at all.
– Daniel Roseman
Jul 25 '15 at 19:52
Where's the rest of that view? What happens if is_valid is not True? Or if it's not a POST?
– Daniel Roseman
Jul 25 '15 at 19:46
Where's the rest of that view? What happens if is_valid is not True? Or if it's not a POST?
– Daniel Roseman
Jul 25 '15 at 19:46
I don't have the rest, I didn't know I needed one, what should I write it the "else:"?
– Nuri Katsuki
Jul 25 '15 at 19:50
I don't have the rest, I didn't know I needed one, what should I write it the "else:"?
– Nuri Katsuki
Jul 25 '15 at 19:50
In that case you would definitely get an exception, because every view must return a response. If your form is not valid but you are not getting an exception, you cannot be using this view at all.
– Daniel Roseman
Jul 25 '15 at 19:52
In that case you would definitely get an exception, because every view must return a response. If your form is not valid but you are not getting an exception, you cannot be using this view at all.
– Daniel Roseman
Jul 25 '15 at 19:52
add a comment |
1 Answer
1
active
oldest
votes
You are missing the else portion within your view. Here is the general flow of what forms usually do:
- Users navigate to a page via
GETwhich presents them with a form - Users fill in the form and submit it by using
POST
- If the form is valid, users are directed to a different page
- If the form is not valid, users are presented with the same page as in step 1 with the validation errors displayed. After users correct them, they are process to step 2.
Here is that flow in django view:
def AddArticle(request):
if request.method == 'POST':
form = ArticleForm(request.POST, request.FILES)
if form.is_valid():
save_it = form.save(commit=False)
save_it.user = request.user
save_it.save()
form.save_m2m()
return HttpResponseRedirect('/')
else:
form = ArticleForm()
return render(request, 'template.html', {'form': form'})
I would however look into using class based views in Django. Initially they can seem very confusing but over time you will learn to appreciate them. Docs. Another useful resource when learning CBV.
By using CBV, the above can be simplified to:
class AddArticleView(CreateView):
success_url = 'name_of_view_here'
form_class = ArticleForm
template_name = 'template.html'
# urls.py
urlpatterns = patterns('', url(r'^articles/add/$', AddArticleView.as_view()))
Template
You also need to include the overall form error in the template, in addition to each field errors:
<form class="form" action="{% url "article.views.AddArticle" %}" method="post" enctype='multipart/form-data'>
{% csrf_token %}
{{ form.non_field_errors }}
...
</form>
Please note that you might need to wrap the errors with some bootstrap markup. More info in docs
But the mystery is that the view couldn't possibly have worked the way it is now, so there is something OP is not telling us.
– Daniel Roseman
Jul 25 '15 at 20:05
I just tried it but it's kind of weird because I still don't get the error message...
– Nuri Katsuki
Jul 25 '15 at 20:06
@DanielRoseman I think I said everything, I don't know if it could help but I am using Ckeditor with the form, it's a form that will let me publish articles for the blog.
– Nuri Katsuki
Jul 25 '15 at 20:10
@miki725 The validation works fine, thanks but the message still doesn't show up...
– Nuri Katsuki
Jul 25 '15 at 20:17
@Sia can you post your complete form template since currently you only posted template for a single form field
– miki725
Jul 25 '15 at 20:51
|
show 5 more comments
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f31630436%2fdjango-validationerror-does-not-display%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You are missing the else portion within your view. Here is the general flow of what forms usually do:
- Users navigate to a page via
GETwhich presents them with a form - Users fill in the form and submit it by using
POST
- If the form is valid, users are directed to a different page
- If the form is not valid, users are presented with the same page as in step 1 with the validation errors displayed. After users correct them, they are process to step 2.
Here is that flow in django view:
def AddArticle(request):
if request.method == 'POST':
form = ArticleForm(request.POST, request.FILES)
if form.is_valid():
save_it = form.save(commit=False)
save_it.user = request.user
save_it.save()
form.save_m2m()
return HttpResponseRedirect('/')
else:
form = ArticleForm()
return render(request, 'template.html', {'form': form'})
I would however look into using class based views in Django. Initially they can seem very confusing but over time you will learn to appreciate them. Docs. Another useful resource when learning CBV.
By using CBV, the above can be simplified to:
class AddArticleView(CreateView):
success_url = 'name_of_view_here'
form_class = ArticleForm
template_name = 'template.html'
# urls.py
urlpatterns = patterns('', url(r'^articles/add/$', AddArticleView.as_view()))
Template
You also need to include the overall form error in the template, in addition to each field errors:
<form class="form" action="{% url "article.views.AddArticle" %}" method="post" enctype='multipart/form-data'>
{% csrf_token %}
{{ form.non_field_errors }}
...
</form>
Please note that you might need to wrap the errors with some bootstrap markup. More info in docs
But the mystery is that the view couldn't possibly have worked the way it is now, so there is something OP is not telling us.
– Daniel Roseman
Jul 25 '15 at 20:05
I just tried it but it's kind of weird because I still don't get the error message...
– Nuri Katsuki
Jul 25 '15 at 20:06
@DanielRoseman I think I said everything, I don't know if it could help but I am using Ckeditor with the form, it's a form that will let me publish articles for the blog.
– Nuri Katsuki
Jul 25 '15 at 20:10
@miki725 The validation works fine, thanks but the message still doesn't show up...
– Nuri Katsuki
Jul 25 '15 at 20:17
@Sia can you post your complete form template since currently you only posted template for a single form field
– miki725
Jul 25 '15 at 20:51
|
show 5 more comments
You are missing the else portion within your view. Here is the general flow of what forms usually do:
- Users navigate to a page via
GETwhich presents them with a form - Users fill in the form and submit it by using
POST
- If the form is valid, users are directed to a different page
- If the form is not valid, users are presented with the same page as in step 1 with the validation errors displayed. After users correct them, they are process to step 2.
Here is that flow in django view:
def AddArticle(request):
if request.method == 'POST':
form = ArticleForm(request.POST, request.FILES)
if form.is_valid():
save_it = form.save(commit=False)
save_it.user = request.user
save_it.save()
form.save_m2m()
return HttpResponseRedirect('/')
else:
form = ArticleForm()
return render(request, 'template.html', {'form': form'})
I would however look into using class based views in Django. Initially they can seem very confusing but over time you will learn to appreciate them. Docs. Another useful resource when learning CBV.
By using CBV, the above can be simplified to:
class AddArticleView(CreateView):
success_url = 'name_of_view_here'
form_class = ArticleForm
template_name = 'template.html'
# urls.py
urlpatterns = patterns('', url(r'^articles/add/$', AddArticleView.as_view()))
Template
You also need to include the overall form error in the template, in addition to each field errors:
<form class="form" action="{% url "article.views.AddArticle" %}" method="post" enctype='multipart/form-data'>
{% csrf_token %}
{{ form.non_field_errors }}
...
</form>
Please note that you might need to wrap the errors with some bootstrap markup. More info in docs
But the mystery is that the view couldn't possibly have worked the way it is now, so there is something OP is not telling us.
– Daniel Roseman
Jul 25 '15 at 20:05
I just tried it but it's kind of weird because I still don't get the error message...
– Nuri Katsuki
Jul 25 '15 at 20:06
@DanielRoseman I think I said everything, I don't know if it could help but I am using Ckeditor with the form, it's a form that will let me publish articles for the blog.
– Nuri Katsuki
Jul 25 '15 at 20:10
@miki725 The validation works fine, thanks but the message still doesn't show up...
– Nuri Katsuki
Jul 25 '15 at 20:17
@Sia can you post your complete form template since currently you only posted template for a single form field
– miki725
Jul 25 '15 at 20:51
|
show 5 more comments
You are missing the else portion within your view. Here is the general flow of what forms usually do:
- Users navigate to a page via
GETwhich presents them with a form - Users fill in the form and submit it by using
POST
- If the form is valid, users are directed to a different page
- If the form is not valid, users are presented with the same page as in step 1 with the validation errors displayed. After users correct them, they are process to step 2.
Here is that flow in django view:
def AddArticle(request):
if request.method == 'POST':
form = ArticleForm(request.POST, request.FILES)
if form.is_valid():
save_it = form.save(commit=False)
save_it.user = request.user
save_it.save()
form.save_m2m()
return HttpResponseRedirect('/')
else:
form = ArticleForm()
return render(request, 'template.html', {'form': form'})
I would however look into using class based views in Django. Initially they can seem very confusing but over time you will learn to appreciate them. Docs. Another useful resource when learning CBV.
By using CBV, the above can be simplified to:
class AddArticleView(CreateView):
success_url = 'name_of_view_here'
form_class = ArticleForm
template_name = 'template.html'
# urls.py
urlpatterns = patterns('', url(r'^articles/add/$', AddArticleView.as_view()))
Template
You also need to include the overall form error in the template, in addition to each field errors:
<form class="form" action="{% url "article.views.AddArticle" %}" method="post" enctype='multipart/form-data'>
{% csrf_token %}
{{ form.non_field_errors }}
...
</form>
Please note that you might need to wrap the errors with some bootstrap markup. More info in docs
You are missing the else portion within your view. Here is the general flow of what forms usually do:
- Users navigate to a page via
GETwhich presents them with a form - Users fill in the form and submit it by using
POST
- If the form is valid, users are directed to a different page
- If the form is not valid, users are presented with the same page as in step 1 with the validation errors displayed. After users correct them, they are process to step 2.
Here is that flow in django view:
def AddArticle(request):
if request.method == 'POST':
form = ArticleForm(request.POST, request.FILES)
if form.is_valid():
save_it = form.save(commit=False)
save_it.user = request.user
save_it.save()
form.save_m2m()
return HttpResponseRedirect('/')
else:
form = ArticleForm()
return render(request, 'template.html', {'form': form'})
I would however look into using class based views in Django. Initially they can seem very confusing but over time you will learn to appreciate them. Docs. Another useful resource when learning CBV.
By using CBV, the above can be simplified to:
class AddArticleView(CreateView):
success_url = 'name_of_view_here'
form_class = ArticleForm
template_name = 'template.html'
# urls.py
urlpatterns = patterns('', url(r'^articles/add/$', AddArticleView.as_view()))
Template
You also need to include the overall form error in the template, in addition to each field errors:
<form class="form" action="{% url "article.views.AddArticle" %}" method="post" enctype='multipart/form-data'>
{% csrf_token %}
{{ form.non_field_errors }}
...
</form>
Please note that you might need to wrap the errors with some bootstrap markup. More info in docs
edited Jul 25 '15 at 23:00
answered Jul 25 '15 at 20:04
miki725miki725
16.5k1371103
16.5k1371103
But the mystery is that the view couldn't possibly have worked the way it is now, so there is something OP is not telling us.
– Daniel Roseman
Jul 25 '15 at 20:05
I just tried it but it's kind of weird because I still don't get the error message...
– Nuri Katsuki
Jul 25 '15 at 20:06
@DanielRoseman I think I said everything, I don't know if it could help but I am using Ckeditor with the form, it's a form that will let me publish articles for the blog.
– Nuri Katsuki
Jul 25 '15 at 20:10
@miki725 The validation works fine, thanks but the message still doesn't show up...
– Nuri Katsuki
Jul 25 '15 at 20:17
@Sia can you post your complete form template since currently you only posted template for a single form field
– miki725
Jul 25 '15 at 20:51
|
show 5 more comments
But the mystery is that the view couldn't possibly have worked the way it is now, so there is something OP is not telling us.
– Daniel Roseman
Jul 25 '15 at 20:05
I just tried it but it's kind of weird because I still don't get the error message...
– Nuri Katsuki
Jul 25 '15 at 20:06
@DanielRoseman I think I said everything, I don't know if it could help but I am using Ckeditor with the form, it's a form that will let me publish articles for the blog.
– Nuri Katsuki
Jul 25 '15 at 20:10
@miki725 The validation works fine, thanks but the message still doesn't show up...
– Nuri Katsuki
Jul 25 '15 at 20:17
@Sia can you post your complete form template since currently you only posted template for a single form field
– miki725
Jul 25 '15 at 20:51
But the mystery is that the view couldn't possibly have worked the way it is now, so there is something OP is not telling us.
– Daniel Roseman
Jul 25 '15 at 20:05
But the mystery is that the view couldn't possibly have worked the way it is now, so there is something OP is not telling us.
– Daniel Roseman
Jul 25 '15 at 20:05
I just tried it but it's kind of weird because I still don't get the error message...
– Nuri Katsuki
Jul 25 '15 at 20:06
I just tried it but it's kind of weird because I still don't get the error message...
– Nuri Katsuki
Jul 25 '15 at 20:06
@DanielRoseman I think I said everything, I don't know if it could help but I am using Ckeditor with the form, it's a form that will let me publish articles for the blog.
– Nuri Katsuki
Jul 25 '15 at 20:10
@DanielRoseman I think I said everything, I don't know if it could help but I am using Ckeditor with the form, it's a form that will let me publish articles for the blog.
– Nuri Katsuki
Jul 25 '15 at 20:10
@miki725 The validation works fine, thanks but the message still doesn't show up...
– Nuri Katsuki
Jul 25 '15 at 20:17
@miki725 The validation works fine, thanks but the message still doesn't show up...
– Nuri Katsuki
Jul 25 '15 at 20:17
@Sia can you post your complete form template since currently you only posted template for a single form field
– miki725
Jul 25 '15 at 20:51
@Sia can you post your complete form template since currently you only posted template for a single form field
– miki725
Jul 25 '15 at 20:51
|
show 5 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f31630436%2fdjango-validationerror-does-not-display%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Where's the rest of that view? What happens if is_valid is not True? Or if it's not a POST?
– Daniel Roseman
Jul 25 '15 at 19:46
I don't have the rest, I didn't know I needed one, what should I write it the "else:"?
– Nuri Katsuki
Jul 25 '15 at 19:50
In that case you would definitely get an exception, because every view must return a response. If your form is not valid but you are not getting an exception, you cannot be using this view at all.
– Daniel Roseman
Jul 25 '15 at 19:52