This file contains hidden or 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
if pelicula.director_id: | |
mi_funcion() | |
mi_funcion(pelicula.director_id) |
This file contains hidden or 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
if pelicula.director: | |
mi_funcion() | |
# tambien se presenta este problema cuando hacemos esto: | |
mi_funcion(pelicula.director.id) |
This file contains hidden or 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
class Director(models.Model): | |
nombre = models.CharField(max_length=100) | |
class Pelicula(models.Model): | |
nombre = models.CharField(max_length=100) | |
autor = models.ForeignKey('Director', null=True) |
This file contains hidden or 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from datetime import datetime, date | |
def is_date(date, valid_formats): | |
''' Devuelve un objeto "datetime" si la cadena ingresada tiene alguno de | |
los patrones de fecha en "valid_formats". ''' | |
for fmt in valid_formats: | |
try: |
This file contains hidden or 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
from django.db import models | |
# para todos los ejemplos de este gist, vamos a utilizar el modelo "Human" | |
class Human(models.Model): | |
'''Modelo de ejemplo que representa | |
un humano y sus atributos. | |
''' | |
first_name = models.CharField(max_length=30) | |
last_name = models.CharField(max_length=30) | |
birth_date = models.DateField() |