Tesis 1.0.0
Loading...
Searching...
No Matches
models.py
Go to the documentation of this file.
1from django.db import models
2
3# Create your models here.
4
5class CategoriaProducto(models.Model):
6 id_categoria = models.AutoField(primary_key=True)
7 nombre_categoria = models.CharField(max_length=45)
8 descripcion = models.CharField(max_length=45)
9
10 class Meta:
11 managed = True
12 db_table = 'categoria_producto'
13 verbose_name = 'Categoriaproducto'
14 verbose_name_plural = 'Categoriaproductos'
15 def __unicode__(self):
16 return self.nombre_categoria
17 def __str__(self):
18 return self.nombre_categoria
19
20
21class Producto(models.Model):
22 id_producto = models.AutoField(primary_key=True)
23 nombre_producto = models.CharField(max_length=45)
24 descripcion = models.CharField(max_length=200)
25 precio = models.FloatField()
26 stock = models.IntegerField(default = 0 )
27 imageURL = models.CharField( max_length=100, null=True )
28 id_categoria = models.ForeignKey(CategoriaProducto, models.DO_NOTHING)
29
30 class Meta:
31 managed = True
32 db_table = 'producto'
33 verbose_name = 'Producto'
34 verbose_name_plural = 'Productos'
35 def __unicode__(self):
36 return self.nombre_producto
37 def __str__(self):
38 return self.nombre_producto
39
40