This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from __future__ import unicode_literals | |
from django.db import models | |
# Create your models here. | |
class Alumno(models.Model): | |
ApellidoPaterno= models.CharField(max_length=35) | |
ApellidoMaterno = models.CharField(max_length=35) | |
Nombres = models.CharField(max_length=35) | |
DNI=models.CharField(max_length=8) | |
FechaNacimiento=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.ApellidoPaterno,self.ApellidoMaterno,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) | |
No hay comentarios:
Publicar un comentario