1👍
✅
There are many ways to define a custom user model.
If you want to add one field you can basically extend the existing user model:
from django.contrib.auth.models import AbstractBaseUser
class MyUser(AbstractBaseUser):
country = models.ForeignKey(Country, models.SET_NULL, blank=True, null=True)
And set AUTH_USER_MODEL
in your settings module:
AUTH_USER_MODEL = 'yourapp.MyUser'
1👍
You would do that using the OneToOneField found here.
- Create an app (e.g.
python manage.py startapp profile
) - Add the app to your settings.py file
- In your profile/models.py file, add the below example
from django.contrib.auth.models import User
class Profile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
country = models.CharField('country', max_length=120)
- [Answered ]-Django is unable to load angular chunks
- [Answered ]-Understanding VIew evaluation in Django
- [Answered ]-Access args in render function in django
- [Answered ]-Is there a way to call a function in ListView?
Source:stackexchange.com