Overview
TheProyectos model represents projects in the system. Each project has a name, a project leader, and can have multiple team members assigned to it. This model inherits from ModeloBase, which provides automatic timestamping and soft delete functionality.
Model Definition
Fields
Direct Fields
The name of the project.Constraints:
- Maximum length: 100 characters
- Required field (cannot be null or blank)
Reference to the team member who leads this project.Relationship Details:
- References:
encargadomodel - On Delete:
CASCADE- deleting the team member will delete the project - Related Name:
proyectos_lider- access from encargado asencargado.proyectos_lider.all() - Required field
Multiple team members assigned to work on this project.Relationship Details:
- References:
encargadomodel - Related Name:
proyectos_encargados- access from encargado asencargado.proyectos_encargados.all() - Can have zero or more team members
Inherited Fields (from ModeloBase)
The date when the project was created.Constraints:
- Automatically set on creation (
auto_now_add=True) - Read-only after creation
- Verbose name: “Fecha Registro”
The time when the project was created.Constraints:
- Automatically set on creation (
auto_now_add=True) - Read-only after creation
- Verbose name: “Hora Registro”
Indicates whether the project is active or deleted (soft delete).Constraints:
- Default value:
True(active) - Set to
Falsefor soft deletion
Model Relationships
Forward Relationships
Access the project leader:
Access all team members assigned to the project:
Reverse Relationships
The
Proyectos model does not have any reverse relationships from other models.String Representation
The model’s__str__() method returns the project name:
Usage Examples
Creating a Project
Querying Projects
Soft Deleting a Project
Database Table
This model is stored in the database table:CTP_proyectos