Capitalize words for the Post title

master
Laurent 6 years ago
parent bc68340b9d
commit 1370240f86
  1. 4
      news/models.py
  2. 2
      news/templates/news/index.html
  3. 2
      news/templates/news/post.html

@ -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)

@ -31,7 +31,7 @@
<img src="{% static 'media/' %}{{ post.image_url }}"/>
<div class="inside_image_top">
{% if post.url %}<a href="{{ post.url }}">{% endif %}
<h1><span>{{ post.title }}</span></h1>
<h1><span>{{ post.formatted_title }}</span></h1>
{% if post.url %}</a>{% endif %}
{% if post.body %}

@ -20,7 +20,7 @@
<div class="quote">
{% endif %}
{% if post.style != 2 and post.style != 3 %}
<a href="{{ post.url }}"><h1>{{ post.title }}</h1></a>
<a href="{{ post.url }}"><h1>{{ post.formatted_title }}</h1></a>
{% endif %}
{% if post.style == 1 %}
</div>

Loading…
Cancel
Save