Django 1.4.2 プロジェクトを実行しています。クラス User(models.Model) のデータベースがあり、django.contrib.auth.models の組み込みモデル User を使用するようにこれを変更したいと考えています。既存のコードを使用して、独自のカスタム User モデルを 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 User モデルのサブクラスにした後、Django South を使用して移行しようとすると、user_ptr の値を設定するように求められます。このフィールドに関する情報は見つかりませんでした。
一般に、この方法で単純にサブクラス化するのは安全ではありませんか? すでに持っているすべてのユーザー データを失い、最初からやり直すわけにはいきません。パスワードとメールのフィールドは、Django のバージョンのフィールドと競合するため、コメント アウトされていることに注意してください。