I am creating an application in which a user registers with a username, email, and password. This data is stored in one table. But then the user enters profile information such as photo, bio, activity and such. Do I store this data in the same table as the username, email, and password? Or do I create another table in which I link those in some way?
CodePudding user response:
you can create a different table UserProfile with OneToOne relation.
class UserProfile(models.Model):
user = models.ForeignKey(User, unique=True)
location = models.CharField(max_length=140)
bio = models.CharField(max_length=140)
profile_picture = models.ImageField(upload_to='profile_pics', blank=True)
Then in settings.py:
AUTH_PROFILE_MODULE = 'accounts.UserProfile'
for uploading you can use diff services aswell like s3 etc
CodePudding user response:
You want to extend User model to have other information. The recomended approach for this is to create another model like Profile and setup OneToOne relation to the User.