Skip to content

Instantly share code, notes, and snippets.

@delgadofarid
Created June 16, 2018 17:17
Show Gist options
  • Save delgadofarid/1bfab6ef080b9cde5dcc46eac396e903 to your computer and use it in GitHub Desktop.
Save delgadofarid/1bfab6ef080b9cde5dcc46eac396e903 to your computer and use it in GitHub Desktop.
Corrección Manual Django Semana 2 - 5. Modelos de Django
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
@pyjavo
Copy link

pyjavo commented Jun 18, 2018

¡Hecho!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment