This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
form data = { | |
"nested": { | |
"key_a": "value", | |
"key_b": "value" | |
}, | |
"not_nested_key": "value" | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# append static urls in root urls.py file | |
from django.contrib.staticfiles.urls import staticfiles_urlpatterns | |
urlpatterns += staticfiles_urlpatterns | |
# add below line in settings.py file | |
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')] | |
# above setting works when DEBUG is True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
class Employee(models.Model): | |
email = models.EmailField() | |
password = models.CharField(max_length=64) | |
class DeductionClaimTypeEnum(models.TextChoices): | |
HRA = "HRA" | |
LTA = "LTA" | |
HOME_LOAN_INTEREST = "Home Loan Interest" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
class Employee(models.Model): | |
email = models.EmailField() | |
password = models.CharField(max_length=64) | |
salary_structure = models.OneToOneField("SalaryStructure", on_delete=models.DO_NOTHING, related_name="salary_structure_employee") | |
class SalaryStructure(models.Model): | |
employee = models.ForeignKey("Employee", on_delete=models.DO_NOTHING, related_name="employee_salary_structure_set") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
class Department(models.Model): | |
name = models.CharField(max_length=64, unique=True, db_index=True) | |
class Designation(models.Model): | |
name = models.CharField(max_length=64, unique=True, db_index=True) | |
class Level(models.IntegerChoices): | |
ONE = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
class Employee(models.Model): | |
email = models.EmailField(unique=True, db_index=True) | |
password = models.CharField(max_length=128) | |
manager = models.ForeignKey("self", on_delete=models.DO_NOTHING, null=True, related_name="manager_employee_set") | |
class ExpenseClaimStatusEnum(TextChoices): | |
PENDING = "Pending" | |
APPROVED = "Approved" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
class OverTimeRequestStatusEnum(models.TextChoices): | |
PENDING = "Pending" | |
APPROVED = "Approved" | |
REJECTED = "Rejected" | |
class Employee(models.Model): | |
email = models.EmailField(unique=True, db_index=True) # email id of employee |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
class Employee(models.Model): | |
email = models.EmailField(unique=True, db_index=True) # email id of employee | |
password = models.CharField(max_length=128) # password of employee | |
class Attendance(models.Model): | |
employee = models.ForeignKey("Employee", on_delete=models.DO_NOTHING) # employee who punched | |
punch_in = models.BooleanField(null=True) # True: in, False: out | |
created_on = models.DateTimeField(auto_now_add=True) # date and time of punch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
class LeaveTypeEnum(models.TextChoices): | |
CASUAL = "Casual" | |
SICK = "Sick" | |
EARNED = "Earned" | |
MATERNITY = "Maternity" | |
PATERNITY = "Paternity" | |
BEREAVEMENT = "Bereavement" | |
COMPASSIONATE = "Compassionate" |