Advertisement
Guest User

Untitled

a guest
Dec 10th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. from django.db import models
  2. # from django import forms
  3.  
  4. # Create your models here.
  5. class Diario(models.Model):
  6. nombre = models.CharField(max_length=100)
  7. pais = models.CharField(max_length=100)
  8. idioma = models.CharField(max_length=100)
  9.  
  10. def __str__(self):
  11. return self.nombre
  12.  
  13. class Usuario(models.Model):
  14. username = models.CharField(max_length=100)
  15. password = models.CharField(max_length=100)
  16. email = models.CharField(max_length=100)
  17. nombre = models.CharField(max_length=100)
  18. apellidos = models.CharField(max_length=100)
  19.  
  20. def __str__(self):
  21. return self.nombre + self.apellidos
  22.  
  23. class Autor(models.Model):
  24. nombre = models.CharField(max_length=100)
  25. apellidos = models.CharField(max_length=100)
  26. email = models.CharField(max_length=100)
  27.  
  28. def __str__(self):
  29. return self.nombre + self.apellidos
  30.  
  31. class Noticia(models.Model):
  32. TIPO_NOTICIAS = (
  33. ("Deportes", "Deportes"),
  34. ("Cultura", "Cultura"),
  35. ("Politica", "Politica"),
  36. ("Economia", "Economia"),
  37. ("Actualidad", "Actualidad"),
  38. )
  39. titular = models.CharField(max_length=100)
  40. fecha = models.DateField()
  41. tipo = models.CharField(max_length=100, choices = TIPO_NOTICIAS)
  42. resumen = models.CharField(max_length=1000)
  43. usuarios = models.ManyToManyField(Usuario)
  44. diario = models.ForeignKey(Diario, on_delete=models.CASCADE)
  45. autores = models.ManyToManyField(Autor)
  46.  
  47. def __str__(self):
  48. return self.titular
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement