I am new in the programming field and I am learning django and python at the same time. I want to create a database with three tables. project, parts and processes. A project can have several pieces, but a piece can not belong to several projects. The part table can have several processes.
in my models.py create the following classes
from django.db import models
# Create your models here.
class Proyecto(models.Model):
PO = models.CharField(max_length=70)
estado = models.CharField(max_length=10)
fechaInicio = models.DateTimeField()
fechaTerminacion = models.DateTimeField()
observaciones = models.TextField(max_length=500)
class Pieza(models.Model):
PO = models.ForeignKey(Proyecto, on_delete=models.CASCADE)
noPlano = models.CharField(max_length=70)
cantidad = models.IntegerField()
responsable = models.CharField(max_length=70)
procesos = models.ForeignKey(Procesos, on_delete=models.CASCADE)
class Procesos(models.Model):
noPlano = models.ForeignKey(Pieza, on_delete=models.CASCADE)
corte = models.BooleanField(default=False)
escuadre = models.BooleanField(default=False)
maquinado = models.BooleanField(default=False)
rectificado = models.BooleanField(default=False)
pulido = models.BooleanField(default=False)
and I have the following problems in the "Parts" class I find an error with the field "processes"
procesos = models.ForeignKey(Procesos, on_delete=models.CASCADE)
NameError: name 'Procesos' is not defined
additional question: how can I make the process table available for the parts table? the idea is that in my template I can display a list of pieces belonging to the same project and that shows the processes that each piece has.