Skip to content

Commit

Permalink
Create Models.py
Browse files Browse the repository at this point in the history
  • Loading branch information
muhammed-ajmal authored Mar 11, 2019
1 parent 2ec3a15 commit a23025b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from django.conf import settings
from django.db import models
from django.utils import timezone


class Post(models.Model):
author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
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

0 comments on commit a23025b

Please sign in to comment.