try and except in api

This commit is contained in:
jain
2023-07-25 12:53:56 +05:30
parent e6d45f3bf2
commit bb56fc7a33
4 changed files with 333 additions and 249 deletions

View File

@ -7,6 +7,7 @@ from django.contrib.auth import get_user_model
from django.contrib.postgres.fields import ArrayField
"""Import django app"""
from base.constants import GENDERS, SIGNUP_METHODS, RELATIONSHIP
"""Define User model"""
User = get_user_model()
# Create your models here.
@ -31,7 +32,7 @@ User = get_user_model()
"""Define junior points model"""
# points of the junior
# position of the junior
# define junior guardian relation model
class Junior(models.Model):
"""Junior model"""
auth = models.ForeignKey(User, on_delete=models.CASCADE, related_name='junior_profile', verbose_name='Email')
@ -109,3 +110,28 @@ class JuniorPoints(models.Model):
def __str__(self):
"""Return email id"""
return f'{self.junior.auth}'
class JuniorGuardianRelationship(models.Model):
"""Junior Guardian relationship model"""
guardian = models.ForeignKey(Guardian, on_delete=models.CASCADE, related_name='guardian', verbose_name='Guardian')
# associated junior with the task
junior = models.ForeignKey(Junior, on_delete=models.CASCADE, related_name='junior', verbose_name='Junior')
# relation between guardian and junior"""
relationship = models.CharField(max_length=31, choices=RELATIONSHIP, null=True, blank=True,
default='1')
"""Profile created and updated time"""
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta(object):
""" Meta class """
db_table = 'junior_guardian_relation'
"""verbose name of the model"""
verbose_name = 'Junior Guardian Relation'
verbose_name_plural = 'Junior Guardian Relation'
def __str__(self):
"""Return email id"""
return f'{self.guardian.user}'