Этот код работает для вышеупомянутого случая
class UserManager(BaseUserManager):
def create_user(self, mobile_no, role, password=None):
"""
Creates and saves a User with the given email and password.
"""
if not mobile_no:
raise ValueError('Users must have an Mobile No')
user = self.model(
mobile_no=mobile_no,
)
user.set_password(password)
user.activated=True
user.save(using=self._db)
return user
def create_superuser(self, mobile_no, role, password):
"""
Creates and saves a superuser with the given email and password.
"""
user = self.create_user(mobile_no, role=role,
password=password
)
user.is_admin = True
user.activated=True
user.save(using=self._db)
return user
def create_staffuser(self, mobile_no, role, password):
"""
Creates and saves a staffuser with the given email and password.
"""
user = self.create_user(mobile_no, role=role,
password=password
)
user.is_staff = True
user.activated=True
user.save(using=self._db)
return user
class Users(AbstractBaseUser, PermissionsMixin):
object = UserManager()
mobile_no = models.IntegerField(_('MobNumber'), null=True, blank=True,unique=True)
email = models.EmailField(_('Email'), max_length=75, null=False, blank=False)
first_name = models.CharField(_('FirstName'), max_length=50, null=True, blank=True)
last_name = models.CharField(_('LastName'), max_length=70, null=True, blank=True)
role = models.CharField(_('Role'), max_length=70, null=True, blank=True)
location = models.CharField(_('Location'), max_length=70, null=True, blank=True)
date_time = models.DateTimeField(_('DateTime'), auto_now=True, null=True, blank=True)
activated = models.BooleanField(_('Activated'), default=False)
is_admin = models.BooleanField(_('is_admin'), default=False)
is_staff = models.BooleanField(_('is_staff'), default=False)
def __unicode__(self):
return str(self.mobile_no)
def __str__(self):
return str(self.mobile_no)
def get_full_name(self):
return self.first_name + " " + self.last_name
class Meta:
ordering = ['-id']
@property
def is_staff(self):
return self.is_admin
def has_perm(self, perm, obj=None):
return self.is_admin
def has_module_perms(self, app_label):
return self.is_admin
USERNAME_FIELD = 'mobile_no'
REQUIRED_FIELDS = ['role']
Уверенный Вы можете.Подробнее:
Ваша проблема с "отклоненным" исполняемым файлом состоит, вероятно в том, что Вы испытываете недостаток в корректном файле манифеста, и/или что vc2008 время выполнения не было (правильно) установлено в системе. Вам, вероятно, нужен этот пакет во время выполнения (собственные распространяемые файлы VS2008, x64 версия) в целевой системе, не использование .msi основывало установку.
Даже в окнах на 64 бита, DLLs все еще имеют свои имена на 32 бита (который, по моему скромному мнению, был плохим выбором, так как он, очевидно, смущает людей). Приложениям на 32 бита по умолчанию перенаправят %systemroot %\system32 к %systemroot %\syswow64 (где DLLs на 32 бита находятся), тогда как приложения на 64 бита не будут перенаправлены. Доступ к реестру приложениями на 32 бита также имеет некоторое включенное перенаправление. Оба могут быть отключены на поток с Wow64DisableWow64FsRedirection (), но очевидно не позволяют приложениям на 32 бита загрузить DLLs на 64 бита.
Так как Вы используете VS2008, необходимо будет или скопировать redist пакет наряду с приложением на тестовой машине или скомпилировать время выполнения как статическая библиотека в рамках кода.