Задать вопрос

Тел: +7 965 3737 888

431

Просмотров

0

Ответов

Validation for full e-mails (e.g. "Joe Hacker ")

<p>Out of the box, Django e-mail fields for both database models and forms only accept plain e-mail addresses. For example, joe@hacker.com is accepted.</p>
<p>On the other hand, full e-mail addresses which include a human-readable name, for example the following address fails validation in Django:</p>
Joe Hacker &lt;joe@hacker.com&gt;

<p>This package adds support for validating full e-mail addresses.</p>
<p><strong>Database model example</strong></p>
from django import models
from full_email.models import FullEmailField

class MyModel(models.Model):
    email = FullEmailField()

<p><strong>Forms example</strong></p>
from django import forms
from full_email.formfields import FullEmailField

class MyForm(forms.Form):
    email = FullEmailField(label='E-mail address')

<p>I maintain this code in a <a href="https://gist.github.com/1505228">GitHub gist</a>. It includes some unit tests as well.</p>

Вопрос полезен? Да0/Нет0
file_5057.py(1.8Кб)
None