Advertisement
Guest User

models

a guest
Jan 18th, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.76 KB | None | 0 0
  1. from django.db import models
  2.  
  3. # Create your models here.
  4. class Agricultura(models.Model):
  5.     producto = models.CharField('Producto', max_length=50)
  6.     temporada = models.CharField('Temporada', max_length=50)
  7.     habitat = models.CharField('Habitat', max_length=50)
  8.     created = models.DateTimeField('Creado', auto_now_add=True)
  9.  
  10.     class Meta:
  11.         ordering = ['created']
  12.  
  13. class Productores(models.Model):
  14.     nombre = models.CharField('Nombre', max_length=50)
  15.     apellido = models.CharField('Apellido', max_length=50)
  16.     apellido2 = models.CharField('Apellido 2', max_length=50)
  17.     direccion = models.CharField('Direccion', max_length=50)
  18.     produce = models.ForeignKey(Agricultura, related_name='productores', on_delete=models.CASCADE)
  19.  
  20.     def __str__(self):
  21.         return self.nombre
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement