diff --git a/news/models.py b/news/models.py index 2c20162..4b2b513 100644 --- a/news/models.py +++ b/news/models.py @@ -4,6 +4,7 @@ from django.conf import settings from django.db.models import Q from django.utils.text import slugify from enum import Enum +import string # Create your models here. class PostState(Enum): @@ -61,6 +62,9 @@ class Post(models.Model): return self.title return 'Poker Rumble - Amazing content' + def formatted_title(self): + return string.capwords(self.title) + class Comment(models.Model): author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, null=True) post = models.ForeignKey(Post, on_delete=models.CASCADE) diff --git a/news/templates/news/index.html b/news/templates/news/index.html index 0e5afbf..5501efa 100644 --- a/news/templates/news/index.html +++ b/news/templates/news/index.html @@ -31,7 +31,7 @@
{% if post.url %}{% endif %} -

{{ post.title }}

+

{{ post.formatted_title }}

{% if post.url %}
{% endif %} {% if post.body %} diff --git a/news/templates/news/post.html b/news/templates/news/post.html index b151e76..22b9c61 100644 --- a/news/templates/news/post.html +++ b/news/templates/news/post.html @@ -20,7 +20,7 @@
{% endif %} {% if post.style != 2 and post.style != 3 %} -

{{ post.title }}

+

{{ post.formatted_title }}

{% endif %} {% if post.style == 1 %}