Skip to content

Revan190/course_djangoHO1.1

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

models.py

from django.core.exceptions import ValidationError from django.db import models

class Company(models.Model): name = models.CharField(max_length=255) address = models.CharField(max_length=255) email = models.EmailField() tax_code = models.CharField(max_length=255)

def save(self, *args, **kwargs):
    if not self.pk and Company.objects.exists():
        raise ValidationError('There can be only one Company instance')
    return super(Company, self).save(*args, **kwargs)

def __str__(self):
    return self.name

class Employee(models.Model): # ... other fields ... phone_number = models.CharField(max_length=20) # Add other necessary fields and methods

class Position(models.Model): # ... other fields ... job_description = models.TextField() # Add other necessary fields and methods

admin.py

from django.contrib import admin from .models import Employee

@admin.register(Employee) class EmployeeAdmin(admin.ModelAdmin): list_display = ('name', 'position', 'phone_number') # Add other configurations if necessary

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 71.4%
  • HTML 28.6%