本文整理匯總了Python中django.db.models.EmailField方法的典型用法代碼示例。如果您正苦於以下問題:Python models.EmailField方法的具體用法?Python models.EmailField怎麽用?Python models.EmailField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類django.db.models
的用法示例。
在下文中一共展示了models.EmailField方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_redirect_url_prefix
# 需要導入模塊: from django.db import models [as 別名]
# 或者: from django.db.models import EmailField [as 別名]
def get_redirect_url_prefix(cls):
"""
Get the url for the change list of this model
:return: a string url
"""
return reverse('%s:%s_%s_changelist' % (
app_settings.RA_ADMIN_SITE_NAME, cls._meta.app_label, cls.get_class_name().lower()))
# class BasePersonInfo(BaseInfo):
# address = models.CharField(_('address'), max_length=260, null=True, blank=True)
# telephone = models.CharField(_('telephone'), max_length=130, null=True, blank=True)
# email = models.EmailField(_('email'), null=True, blank=True)
#
# class Meta:
# abstract = True
# # swappable = swapper.swappable_setting('ra', 'BasePersonInfo')
示例2: get_replacer_for_field
# 需要導入模塊: from django.db import models [as 別名]
# 或者: from django.db.models import EmailField [as 別名]
def get_replacer_for_field(field):
# Some obvious ones:
if isinstance(field, EmailField):
return '"email"'
# Use choices, if available.
choices = getattr(field, 'choices', None)
if choices is not None and len(choices) > 0:
return '"choice"'
field_type = field.get_internal_type()
if field_type == "CharField" or field_type == "TextField":
# Guess by the name
# First, go for complete match
for pattern, result in charfield_replacers:
if re.match(pattern + "$", field.attname):
return result
# Then, go for a partial match.
for pattern, result in charfield_replacers:
if re.search(pattern, field.attname):
return result
# Nothing matched.
if field_type == "TextField":
return '"lorem"'
# Just try some random chars
return '"varchar"'
try:
r = field_replacers[field_type]
except KeyError:
r = "UNKNOWN_FIELD"
return r
示例3: setup_db_compat_django
# 需要導入模塊: from django.db import models [as 別名]
# 或者: from django.db.models import EmailField [as 別名]
def setup_db_compat_django():
from tri_table import register_column_factory
try:
# noinspection PyUnresolvedReferences
from django.db.models import IntegerField, FloatField, TextField, BooleanField, AutoField, CharField, DateField, DateTimeField, DecimalField, EmailField, TimeField, ForeignKey, ManyToOneRel, ManyToManyField, ManyToManyRel, UUIDField
except ImportError:
pass
else:
# The order here is significant because of inheritance structure. More specific must be below less specific.
register_column_factory(CharField, Shortcut(call_target__attribute='text'))
register_column_factory(UUIDField, Shortcut(call_target__attribute='text'))
register_column_factory(TimeField, Shortcut(call_target__attribute='time'))
register_column_factory(EmailField, Shortcut(call_target__attribute='email'))
register_column_factory(DecimalField, Shortcut(call_target__attribute='decimal'))
register_column_factory(DateField, Shortcut(call_target__attribute='date'))
register_column_factory(DateTimeField, Shortcut(call_target__attribute='datetime'))
register_column_factory(BooleanField, Shortcut(call_target__attribute='boolean'))
register_column_factory(TextField, Shortcut(call_target__attribute='text'))
register_column_factory(FloatField, Shortcut(call_target__attribute='float'))
register_column_factory(IntegerField, Shortcut(call_target__attribute='integer'))
register_column_factory(AutoField, Shortcut(call_target__attribute='integer', show=False))
register_column_factory(ManyToOneRel, None)
register_column_factory(ManyToManyField, Shortcut(call_target__attribute='many_to_many'))
register_column_factory(ManyToManyRel, None)
register_column_factory(ForeignKey, Shortcut(call_target__attribute='foreign_key'))
示例4: test_should_email_convert_string
# 需要導入模塊: from django.db import models [as 別名]
# 或者: from django.db.models import EmailField [as 別名]
def test_should_email_convert_string():
assert_conversion(models.EmailField, graphene.String)
示例5: get_filter_url
# 需要導入模塊: from django.db import models [as 別名]
# 或者: from django.db.models import EmailField [as 別名]
def get_filter_url(self):
return reverse('talk-list') + '?category=%d' % self.pk
#class Attendee(PonyConfModel):
#
# user = models.ForeignKey(User, null=True)
# name = models.CharField(max_length=64, blank=True, default="")
# email = models.EmailField(blank=True, default="")
#
# def get_name(self):
# if self.user:
# return str(self.user.profile)
# else:
# return self.name
# get_name.short_description = _('Name')
#
# def get_email(self):
# if self.user:
# return self.user.email
# else:
# return self.email
# get_email.short_description = _('Email')
#
# def __str__(self):
# return self.get_name()
示例6: test_email_field
# 需要導入模塊: from django.db import models [as 別名]
# 或者: from django.db.models import EmailField [as 別名]
def test_email_field(self):
field = models.EmailField()
name, path, args, kwargs = field.deconstruct()
self.assertEqual(path, "django.db.models.EmailField")
self.assertEqual(args, [])
self.assertEqual(kwargs, {"max_length": 254})
field = models.EmailField(max_length=255)
name, path, args, kwargs = field.deconstruct()
self.assertEqual(path, "django.db.models.EmailField")
self.assertEqual(args, [])
self.assertEqual(kwargs, {"max_length": 255})
示例7: save
# 需要導入模塊: from django.db import models [as 別名]
# 或者: from django.db.models import EmailField [as 別名]
def save(self, **kwargs):
super(SignupCodeResult, self).save(**kwargs)
self.signup_code.calculate_use_count()
# class EmailAddress(models.Model):
#
# user = models.ForeignKey(settings.AUTH_USER_MODEL)
# email = models.EmailField(unique=settings.ACCOUNT_EMAIL_UNIQUE)
# verified = models.BooleanField(_("verified"), default=False)
# primary = models.BooleanField(_("primary"), default=False)
#
# objects = EmailAddressManager()
#
# class Meta:
# verbose_name = _("email address")
# verbose_name_plural = _("email addresses")
# if not settings.ACCOUNT_EMAIL_UNIQUE:
# unique_together = [("user", "email")]
#
# def __unicode__(self):
# return "{0} ({1})".format(self.email, self.user)
#
# def set_as_primary(self, conditional=False):
# old_primary = EmailAddress.objects.get_primary(self.user)
# if old_primary:
# if conditional:
# return False
# old_primary.primary = False
# old_primary.save()
# self.primary = True
# self.save()
# self.user.email = self.email
# self.user.save()
# return True
#
# def send_confirmation(self, **kwargs):
# confirmation = EmailConfirmation.create(self)
# confirmation.send(**kwargs)
# return confirmation
#
# def change(self, new_email, confirm=True):
# """
# Given a new email address, change self and re-confirm.
# """
# with transaction.atomic():
# self.user.email = new_email
# self.user.save()
# self.email = new_email
# self.verified = False
# self.save()
# if confirm:
# self.send_confirmation()
示例8: send
# 需要導入模塊: from django.db import models [as 別名]
# 或者: from django.db.models import EmailField [as 別名]
def send(self, **kwargs):
current_site = kwargs["site"] if "site" in kwargs else Site.objects.get_current()
protocol = getattr(settings, "DEFAULT_HTTP_PROTOCOL", "http")
activate_url = "{0}://{1}{2}".format(
protocol,
current_site.domain,
reverse(settings.ACCOUNT_EMAIL_CONFIRMATION_URL, args=[self.key])
)
ctx = {
"account": self.account,
"user": self.account.user,
"activate_url": activate_url,
"current_site": current_site,
"key": self.key,
}
hookset.send_confirmation_email([self.account.user.email], ctx)
self.sent = timezone.now()
self.save()
signals.email_confirmation_sent.send(sender=self.__class__, confirmation=self)
# class AccountDeletion(models.Model):
#
# user = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, blank=True, on_delete=models.SET_NULL)
# email = models.EmailField()
# date_requested = models.DateTimeField(_("date requested"), default=timezone.now)
# date_expunged = models.DateTimeField(_("date expunged"), null=True, blank=True)
#
# class Meta:
# verbose_name = _("account deletion")
# verbose_name_plural = _("account deletions")
#
# @classmethod
# def expunge(cls, hours_ago=None):
# if hours_ago is None:
# hours_ago = settings.ACCOUNT_DELETION_EXPUNGE_HOURS
# before = timezone.now() - datetime.timedelta(hours=hours_ago)
# count = 0
# for account_deletion in cls.objects.filter(date_requested__lt=before, user__isnull=False):
# settings.ACCOUNT_DELETION_EXPUNGE_CALLBACK(account_deletion)
# account_deletion.date_expunged = timezone.now()
# account_deletion.save()
# count += 1
# return count
#
# @classmethod
# def mark(cls, user):
# account_deletion, created = cls.objects.get_or_create(user=user)
# account_deletion.email = user.email
# account_deletion.save()
# settings.ACCOUNT_DELETION_MARK_CALLBACK(account_deletion)
# return account_deletion