Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. from django.db import models
  2.  
  3. TIPOS_DE_PROYECTO = (
  4.     ('A','Academico'),
  5.     ('P','Profesional'),
  6.     ('D','Publicacion'),
  7.     ('E','Exhibicion')
  8. )
  9.  
  10. class Proyecto(models.Model):
  11.     titulo = models.CharField(max_length=200)
  12.     contenido = models.TextField()
  13.     fecha = models.DateField('fecha de publicacion')
  14.     tipo = models.CharField(max_length=1, choices=TIPOS_DE_PROYECTO)
  15.     def __unicode__(self):
  16.         return self.titulo
  17.  
  18. class Imagenes(models.Model):
  19.     proyecto = models.ForeignKey(Proyecto)
  20.     imagen = models.ImageField(upload_to=("archivo/%s"%proyecto.titulo))
  21.     def __unicode__(self):
  22.         return self.imagen.name
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement