Modified files
app/models.py
---
+++
@@ -16,7 +16,7 @@
class Article(models.Model):
title = models.CharField(max_length=100)
content = models.TextField(blank=True, default="")
- word_count = models.IntegerField()
+ word_count = models.IntegerField(blank=True, default="")
twitter_post = models.TextField(blank=True, default="")
status = models.CharField(
max_length=20,
app/views.py
---
+++
@@ -19,14 +19,14 @@
class ArticleCreateView(CreateView):
template_name = "app/article_create.html"
model = Article
- fields = ["title", "status", "content", "word_count", "twitter_post"]
+ fields = ["title", "status", "content", "twitter_post"]
success_url = reverse_lazy("home")
class ArticleUpdateView(UpdateView):
template_name = "app/article_update.html"
model = Article
- fields = ["title", "status", "content", "word_count", "twitter_post"]
+ fields = ["title", "status", "content", "twitter_post"]
success_url = reverse_lazy("home")
context_object_name = "article"
templates/app/home.html
---
+++
@@ -8,7 +8,7 @@
{% if articles %}
<ul>
{% for article in articles %}
- <li><a href="{% url 'update_article' article.id %}">{{ article.title }}</a> with {{ article.word_count }} words.</li>
+ <li><a href="{% url 'update_article' article.id %}">{{ article.title }}</a> with {{ article.word_count }} wordword{{ article.word_count | pluralize }}.</li>
{% endfor %}
</ul>
{% else %}
templates/app/article_update.html
---
+++
@@ -2,6 +2,7 @@
{% block content %}
<h1>Edit Article</h1>
+ <p>{{ article.word_count }} word{{ article.word_count | pluralize }}.</p>
<p>Last edited on {{ article.updated_at | date:"jS F Y" }}</p>
<form method="POST">
{% csrf_token %}