Created
June 16, 2018 17:17
-
-
Save delgadofarid/1bfab6ef080b9cde5dcc46eac396e903 to your computer and use it in GitHub Desktop.
Corrección Manual Django Semana 2 - 5. Modelos de Django
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 | |
from django.utils import timezone | |
class Post(models.Model): | |
author = models.ForeignKey( | |
'auth.User', | |
on_delete=models.CASCADE, #Cambio incluido | |
) | |
title = models.CharField(max_length=200) | |
text = models.TextField() | |
created_date = models.DateTimeField( | |
default=timezone.now) | |
published_date = models.DateTimeField( | |
blank=True, null=True) | |
def publish(self): | |
self.published_date = timezone.now() | |
self.save() | |
def __str__(self): | |
return self.title |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
¡Hecho!