Back to list

Django Model - User Profile

Lv.5395@mukitaro8 playsDec 28, 2025

Django ORM model definition for user profile. From Django's official tutorial.

preview.python
Python
1from django.db import models
2from django.contrib.auth.models import User
3
4class Profile(models.Model):
5 user = models.OneToOneField(User, on_delete=models.CASCADE)
6 bio = models.TextField(max_length=500, blank=True)
7 location = models.CharField(max_length=30, blank=True)
8 birth_date = models.DateField(null=True, blank=True)
9
10 def __str__(self):
11 return self.user.username

Custom problems are not included in rankings