This commit is contained in:
root
2025-09-29 15:57:17 +03:00
commit 25e571d194
21 changed files with 370 additions and 0 deletions

13
articles/models.py Normal file
View File

@@ -0,0 +1,13 @@
from django.db import models
from django.contrib.auth.models import User
class Article(models.Model):
title = models.CharField(max_length=200)
author = models.ForeignKey(User, on_delete=models.CASCADE)
text = models.TextField()
created_date = models.DateField(auto_now_add=True)
def __unicode__ (self):
return "%s: %s" % (self.author.username, self.title)
def get_excerpt(self):
return self.text[:200] + "..." if len(self.text) > 140 else self.text