Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/LucPinheiro/gestor-tarea-django/llms.txt

Use this file to discover all available pages before exploring further.

The Tarea model is the single database table that powers Gestor de Tareas Django. Every task created, edited, filtered, or exported by the application is stored as a row in this table. Understanding its fields, choice constants, and constraints is the starting point for any backend work on this project.

Model Definition

The full class is defined in tareas/models.py. Two module-level lists — ESTADOS and PRIORIDADES — supply the allowed values for the estado and prioridad fields respectively.
models.py
from django.db import models

ESTADOS = [
    ('Borrador', 'Borrador'),
    ('Pendiente', 'Pendiente'),
    ('En proceso', 'En proceso'),
    ('Completada', 'Completada'),
]

PRIORIDADES = [
    (1, 'Baja'),
    (2, 'Media'),
    (3, 'Alta'),
]

class Tarea(models.Model):
    titulo = models.CharField(max_length=100)
    descripcion = models.TextField()
    estado = models.CharField(max_length=20, choices=ESTADOS, default='Borrador')
    fecha_creada = models.DateTimeField(auto_now_add=True)
    prioridad = models.IntegerField(choices=PRIORIDADES, default=1)
    fecha_limite = models.DateField(null=True, blank=True)

    def __str__(self):
        return self.titulo

Field Reference

Each field listed below corresponds directly to a column in the tareas_tarea database table. Fields marked required must be provided on create/update; fields marked optional may be omitted or left blank.
titulo
CharField
required
The title of the task. Stored as a VARCHAR(100) column. Maximum length of 100 characters; no default value — must be supplied by the caller or the form.
descripcion
TextField
required
A free-form text body for the task. Stored as a TEXT column with no length limit. No default value — must be supplied.
estado
CharField
required
The current workflow state of the task. Stored as a VARCHAR(20). Constrained to the four values defined in ESTADOS (see table below). Defaults to 'Borrador' when not provided.
fecha_creada
DateTimeField
required
The timestamp at which the task was created. Set automatically by Django via auto_now_add=True — it is written once on INSERT and never updated. This field is not editable through forms or the API; any value passed in is silently ignored by Django.
prioridad
IntegerField
required
The numeric priority of the task. Constrained to the three integer values defined in PRIORIDADES (see table below). Defaults to 1 ('Baja') when not provided.
fecha_limite
DateField
An optional deadline date for the task. Stored as a DATE column. Both null=True and blank=True are set, meaning the column accepts NULL in the database and the field may be omitted from forms without a validation error.

Valid Values

ESTADOS — Task States

The estado field accepts only these four string values. The stored value (written to the database) and the display label are identical for all states.
Stored ValueDisplay Label
BorradorBorrador
PendientePendiente
En procesoEn proceso
CompletadaCompletada
The cambiar_estado_simple view accepts the stored string value as a URL path segment — e.g. /cambiar-estado/7/En proceso/. Ensure the value is URL-encoded when constructing links manually.

PRIORIDADES — Task Priorities

The prioridad field accepts only these three integer values. The integer is stored in the database; the label is used for display in templates and the admin.
Stored Value (integer)Display Label
1Baja
2Media
3Alta

ModelForm — TareaForm

TareaForm is a ModelForm defined in tareas/forms.py. It is used by both the crear_tarea and editar_tarea views to validate and persist task data. The form exposes five of the six model fields; fecha_creada is intentionally excluded because Django sets it automatically via auto_now_add=True.
forms.py
from django import forms
from .models import Tarea

class TareaForm(forms.ModelForm):

    class Meta:
        model = Tarea

        fields = [
            'titulo',
            'descripcion',
            'estado',
            'prioridad',
            'fecha_limite'
        ]

        widgets = {
            'titulo': forms.TextInput(attrs={
                'class': 'form-control form-control-lg',
                'placeholder': 'Título de tarea...'
            }),

            'descripcion': forms.Textarea(attrs={
                'class': 'form-control',
                'placeholder': 'Añada detalles sobre esta tarea...',
                'rows': 10
            }),

            'estado': forms.Select(attrs={
                'class': 'form-select form-select-lg'
            }),

            'prioridad': forms.Select(attrs={
                'class': 'form-select form-select-lg'
            }),

            'fecha_limite': forms.DateInput(attrs={
                'class': 'form-control form-control-lg',
                'type': 'date'
            }),
        }
Each widget applies Bootstrap 5 classes (form-control, form-select) and, where appropriate, an HTML placeholder. The fecha_limite widget sets type="date" to trigger the browser’s native date-picker.
fecha_creada is not included in TareaForm.Meta.fields. Attempting to pass it in POST data has no effect — Django’s ModelForm will ignore fields not declared in fields.

Database

The table is managed entirely by Django migrations. Key storage details are listed below.
PropertyValue
BackendSQLite (django.db.backends.sqlite3) — configured in mi_proyecto/settings.py
Database fileBASE_DIR / 'db.sqlite3' (project root)
Table nametareas_tarea — Django convention: <app_label>_<model_name>
Primary keyid — auto-incrementing BigAutoField, sourced from DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' in settings
The prioridad and fecha_limite fields were added in migration 0005_tarea_fecha_limite_tarea_prioridad (tareas/migrations/0005_tarea_fecha_limite_tarea_prioridad.py). If you are working with an older database snapshot, run python manage.py migrate to apply all pending migrations before testing these fields.

Build docs developers (and LLMs) love