32 lines
920 B
Python
Executable File
32 lines
920 B
Python
Executable File
from django.db import models
|
|
from django.urls import reverse
|
|
from django.contrib.auth.models import User
|
|
|
|
|
|
|
|
class Profile(models.Model):
|
|
TIMEZONE_CHOICES = [
|
|
('US/Alaska', 'US/Alaska'),
|
|
('US/Arizona', 'US/Arizona'),
|
|
('US/Central', 'US/Central'),
|
|
('US/Eastern', 'US/Eastern'),
|
|
('US/Hawaii', 'US/Hawaii'),
|
|
('US/Mountain', 'US/Mountain'),
|
|
('US/Pacific', 'US/Pacific'),
|
|
]
|
|
user = models.OneToOneField(User, on_delete=models.CASCADE)
|
|
timezone = models.CharField(
|
|
max_length=50,
|
|
choices = TIMEZONE_CHOICES,
|
|
default='US/Mountain'
|
|
)
|
|
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
updated_at = models.DateTimeField(auto_now=True)
|
|
|
|
def get_absolute_url(self):
|
|
return reverse('profile-detail', kwargs={'pk': self.pk})
|
|
|
|
def __str__(self):
|
|
return f'{self.user.first_name} {self.user.last_name}'
|