![]() # if do not specify the auto_now=True attribute with value then this field can not be created.Įmp_onboard_date = models.DateTimeField(auto_now=True) # should add the () after IntegerField, otherwise the emp_salary column will not be created. # support department and employee table are many to many relationships.ĭept = models.ManyToManyField(Department)Įmp_mobile = models.CharField(max_length=100) User = models.ForeignKey(User, on_delete=models.CASCADE,) # Employee has two foreign key, user(Django built-in auth_user table) and department. ![]() # create Employee model, this model will be mapped to table user_register_login_employee in sqlite db. We set Employee model class’s dept field type to models.ManyToManyField(Department) now. Just change the Employee model class definition in DjangoHelloWorld / dept_emp / models.py file.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |