Skip to content

Instantly share code, notes, and snippets.

@vbmendes
Created September 8, 2010 19:39
Show Gist options
  • Save vbmendes/570698 to your computer and use it in GitHub Desktop.
Save vbmendes/570698 to your computer and use it in GitHub Desktop.
# -*- coding: utf8 -*-
"""
Você pode criar a mensagem no próprio form.
"""
from django import forms
from django.forms.util import ErrorList
from models import UserDoc
class DocForm(forms.ModelForm):
class Meta():
model = UserDoc
def clean(self):
cleaned_data = super(DocForm, self).clean()
if self.errors and not self.errors.has_key('nome_do_campo_file'):
self.errors['nome_do_campo_file'] = ErrorList()
self.errors['nome_do_campo_file'].append(u'Não esqueça de reenviar o arquivo.')
return cleaned_data
{% comment %}
Ou pode colocar diretamente no template.
{% endcomment %}
{% if form.errors %}
Não esqueça de reenviar o arquivo.
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment