我现在很困惑。我在一个项目中有3个应用程序。从Django的命令行创建用户
应用1:从最终用户(Web视图基于应用程序)的使用
应用2:从服务提供商(网络服务)
App3的使用:从系统管理员使用。
我想为每个应用程序使用django身份验证系统。我可以让django项目对App1的用户进行身份验证。但是,我怎样才能同时使用App2和App3的认证系统。
当我运行python manage.py createsuperuser
命令时,django使App1的超级用户。如何使用此命令为App2和App3制作?
有人有什么想法吗?请帮帮我。
Models.py
### This table is for end user.
class RemoshinUser(models.Model):
user = models.OneToOneField(User)
user_type = models.SmallIntegerField(default=1)
kana_name = models.CharField(max_length=128, blank=True)
date_of_birth = models.DateField(blank=True, null=True)
sex = models.SmallIntegerField(null=True)
postno = models.CharField(max_length=7, blank=True)
address1 = models.CharField(max_length=128)
address2 = models.CharField(max_length=128, blank=True)
telno = models.CharField(max_length=16, blank=True)
photo = models.ImageField(upload_to='users/%Y/%m/%d', blank=True)
create_date = models.DateTimeField(auto_now_add=True)
modify_date = models.DateTimeField(auto_now=True)
class Meta:
db_table = 'remosys_remoshin_user_tbl'
swappable = 'AUTH_USER_MODEL'
### This table is for service provider.
class RemoshinDoctor(models.Model):
user = models.OneToOneField(User)
user_type = models.SmallIntegerField(default=2)
doctor_id = models.CharField(max_length=16, primary_key=True)
clinic_id = models.ForeignKey(Clinic)
photo = models.ImageField(blank=True, null=True)
create_date = models.DateTimeField(auto_now_add=True)
modify_date = models.DateTimeField(auto_now=True)
class Meta:
db_table = 'remosys_remoshin_doctor_tbl'
### This table is for system administrator.
class RemoshinManager(models.Model):
user = models.OneToOneField(User)
user_type = models.SmallIntegerField(default=3)
manager_id = models.CharField(max_length=16, primary_key=True)
create_date = models.DateTimeField(default=timezone.now)
modify_date = models.DateTimeField(default=timezone.now)
class Meta:
db_table = 'remosys_remoshin_manager_tbl'
你有每个应用程序的自定义用户模型?我不明白这个问题? –
当你创建一个用户时,是在完全项目中而不是在应用程序中 –
我不使用自定义用户模型。我使用扩展用户的一对一模型。我必须使用自定义用户模型吗? –