First, make sure the field is rendered as an input tag with type
"email". If it's not, your Django version is out of date or you're
overriding the widget somewhere.
Second, read this:
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email#Validation

The standard pattern isn't good enough as it doesn't require a dot in
the domain part.
This is why browser form validation succeeds and Django's fails.
Django could maybe propagate the validator
pattern to the "pattern" attribute of the input tag, but I'm not sure
that even works given various
browser differences in regex implementation.

The following css snippet, would allow you to test the pattern should
you decide to provide one yourself via widget attributes:

input[type='email']:invalid { color: red }


On Tue, Sep 12, 2017 at 5:23 PM, Moreplavec <stanislav.va...@gmail.com> wrote:
> I have {{ field.errors }}  im my template. I changed model to not contain
> blank=True, but problem is still the same.
>
>
> Dne úterý 12. září 2017 15:18:58 UTC+2 Daniel Roseman napsal(a):
>>
>>
>> On Tuesday, 12 September 2017 14:18:29 UTC+1, Daniel Roseman wrote:
>>>
>>> On Tuesday, 12 September 2017 08:52:37 UTC+1, Moreplavec wrote:
>>>>
>>>> <snip>
>>>>>
>>>>> <form action="." method="POST">{% csrf_token %}
>>>>>                         {{ form.non_field_errors }}
>>>>>                         {% for hidden in form.hidden_fields %}
>>>>>                             {{ hidden }}
>>>>>                         {% endfor %}
>>>>>                         {% for field in form.visible_fields %}
>>>>>                         <div class="form-group">
>>>>>                             {% if field.field.required %}
>>>>>                             {{ field.errors }}
>>>>>                                 {{ field.label }}<span
>>>>> class="special_class">*</span>{{ field }}
>>>>>                             {% else  %}
>>>>>                                 {{ field.label }} {{ field }}
>>>>>                             {% endif %}
>>>>>                         </div>
>>>>>                         {% endfor %}
>>>
>>>
>>>>> <snip>
>>>
>>>
>>> For some reason, you only show `{{ form.errors }}` if the field is
>>> required; and your email is not (becase you have blank=True in the model for
>>> that field).
>>>
>>> Move the form.errors element out of that if block.
>>> --
>>> DR.
>>
>>
>> Sorry, that should have been `{{ field.errors }}`.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/14a999b0-7bfc-4f5c-9215-b739e1ebf5e9%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



-- 
Melvyn Sopacua

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Bgw1GVbpeS4Ci97nVOdLez_o-JrmzDz1s%2BC8h4PsuNDBZU78g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to