Problems with foreign key

I’m learning to use models with relationships to other tables

class Stock(models.Model): #Modelo del stock
    cod_art = models.IntegerField(primary_key=True)
    descripcion = models.CharField(max_length=50)
    stock = models.IntegerField()
    class Meta:
        managed = False
        db_table = 'stock'

class Pedido(models.Model):   #Modelo para los pedidos
    cod_pedido = models.AutoField(primary_key=True)
    #cod_detalle = models.IntegerField()
    cod_detalle = models.ForeignKey(Stock, on_delete=models.CASCADE)
    user= models.CharField(max_length=50)
    class Meta:
        managed = False
        db_table = 'pedido'

I have these 2 tables: “Orders” and “Stock”. My problem is when creating an order, I want to store the product ID and when performing the .save() I get the following error
(1054, “Unknown column ‘cod_detalle_id’ in ‘field list’”)

The code he made to save it in the database is this:

    s = Stock(cod_art = 8 , descripcion = "lapicera verde", stock = 10)
    
    s.save()
    
    p = Pedido.objects.create( cod_detalle = s , user = 44 )

Side note: When requesting assistance with an error message, please post the complete traceback of the message, along with the complete function being executed where the error occurs.

In this case, also please include any save methods that you may have implemented in the model or form.

Sorry for not putting all the information!
I kept looking for information and managed to solve it by adding the “db_column” argument

cod_detalle = models.ForeignKey(Stock, on_delete=models.CASCADE, db_column='cod_detalle')