我正在運行Django 1.4.2項目。我有一個類User(models.Model)的數據庫,現在想改變它,以便我使用來自django.contrib.auth.models的內置模型User。我可以簡單地使用我現有的代碼,並簡單地將我自己的custon User模型構建爲一個Django的子類嗎?現在是模型。將現有模型遷移到Django內置用戶模型
class User(models.Model):
u_id = models.AutoField(primary_key=True)
#password = models.CharField(max_length=765)
old_password = models.CharField(max_length=765, null=True, blank=True)
birthday = models.DateField(null=True, blank=True)
school_year = models.CharField(max_length=765, blank=True)
gender = models.CharField(max_length=18, blank=True)
#email = models.CharField(max_length=765, blank=True)
profile_pic = models.CharField(max_length=765, blank=True)
is_cloudinary_pic = models.BooleanField(default=False)
fb_id = models.CharField(max_length=765, blank=True)
phone_num = models.CharField(max_length=765, blank=True)
name = models.CharField(max_length=765, blank=True)
confirmcode = models.CharField(max_length=765, blank=True)
status = models.CharField(max_length=765, blank=True)
netid = models.CharField(max_length=765, blank=True)
favorites = models.ManyToManyField('listings.Listing', blank=True, related_name='favorites')
stripe = models.CharField(max_length=765, blank=True)
rating = models.IntegerField(null=True, blank=True)
preferences = models.CharField(max_length=765, blank=True)
b_notification = models.CharField(max_length=765, blank=True)
l_notification = models.CharField(max_length=765, blank=True)
address = models.CharField(max_length=765, blank=True)
city = models.CharField(max_length=765, blank=True)
state = models.CharField(max_length=6, blank=True)
zip = models.CharField(max_length=15, blank=True)
emailprefs = models.CharField(max_length=30, blank=True)
exp_month = models.CharField(max_length=6, blank=True)
exp_year = models.CharField(max_length=12, blank=True)
last4 = models.CharField(max_length=12, blank=True)
c_type = models.CharField(max_length=765, blank=True)
user_type = models.CharField(max_length=10, blank=True)
contract = models.ForeignKey('contracts.Contract', null=True,blank=True, default=None, on_delete=models.SET_NULL)
last_listing_booked = models.ForeignKey('listings.Listing', null=True,blank=True, default=None, on_delete=models.SET_NULL, related_name='last_listing_booked')
last_locked_on = models.IntegerField(null=True, blank=True)
waitlist_number = models.IntegerField(null=True, blank=True)
waitlist_listing = models.ForeignKey('listings.Listing', null=True, blank=True, on_delete=models.SET_NULL, related_name='waitlist_listing')
uploaded_contract = models.FileField(upload_to=contract_file_name, max_length=765, null=True, blank=True, default=None, storage=FileSystemStorage(location=os.path.join(MEDIA_ROOT, 'contracts')))
當我嘗試使用Django南使我的模型Django的用戶模型的一個子類後遷移,我被要求設置一個user_ptr價值,對此我已經成功找到任何信息的字段。
一般來說,以這種方式簡單分類是不安全的嗎?我無法承受已經擁有的所有用戶數據並重新開始。請注意,密碼和電子郵件字段已被註釋掉,因爲它們與Django版本的這些字段衝突。