Skip to content

Instantly share code, notes, and snippets.

@brandon22esquivel
Last active May 13, 2020 23:40
Show Gist options
  • Save brandon22esquivel/064a9ad25f3f8fdc1d4239bcc6fa4dcc to your computer and use it in GitHub Desktop.
Save brandon22esquivel/064a9ad25f3f8fdc1d4239bcc6fa4dcc to your computer and use it in GitHub Desktop.
Modelo de datos para nuestra segunda aplicacion
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models
# Create your models here.
class Alumno(models.Model):
Apellido_Paterno = models.CharField(max_length=35)
Apellido_Materno = models.CharField(max_length=35)
Nombres = models.CharField(max_length=35)
DNI = models.CharField(max_length=8)
Fecha_Nacimiento = models.DateField()
SEXOS = (('F', 'Femenino'), ('M', 'Masculino'))
sexo = models.CharField(max_length=1, choices=SEXOS, default='M')
#foto=models.ImageField(upload_to='photos')
#def NombreCompleto(self):
# cadena = "{0} {1} {2}"
# return cadena.format(self.Apellido_Paterno,self.Apellido_Materno,self.Nombres)
#def __str__(self):
# return self.NombreCompleto()
class Curso(models.Model):
Nombre = models.CharField(max_length=30)
Estado = models.BooleanField(default=True)
Creditos = models.PositiveIntegerField(default=1)
#def __str__(self):
# return "{0} -> {1}".format(self.Nombre,self.Creditos)
class Matricula(models.Model):
Alumno = models.ForeignKey(Alumno, null=False, blank=False, on_delete=models.CASCADE)
Curso = models.ForeignKey(Curso, null=False, blank=False, on_delete=models.CASCADE)
FechaMatricula = models.DateTimeField(auto_now=True)
#def __str__(self):
# cadena= "{0} inscrito en: {1}"
# return cadena.format(self.Alumno, self.Curso)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment