Fix profile model. Add OneToOne relation, fix image dir path

This commit is contained in:
Andrew Smirnov 2021-02-04 20:40:56 +03:00
parent 234669242f
commit 5e5bec6028
No known key found for this signature in database
GPG Key ID: 0EFE318E5BB2A82A

View File

@ -1,8 +1,10 @@
import os import os
from django.contrib.auth.models import User
from django.db import models from django.db import models
class UserProfile(models.Model): class UserProfile(models.Model):
user = models.OneToOneField(to=User, on_delete=models.CASCADE)
role = models.IntegerField() role = models.IntegerField()
image = models.ImageField(upload_to=os.path.join('media', 'user_avatars')) image = models.ImageField(upload_to='user_avatars')