{{ post.content|safe }}
16 | 17 |{{ post.content|safe|truncatewords:80 }}
12 | {% trans 'Category' %} 13 | : {{ post.category.title }} 14 |{% trans 'Database is empty' %}
18 | {% endfor %} 19 | 20 | {% endblock %} -------------------------------------------------------------------------------- /blog/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /blog/translation.py: -------------------------------------------------------------------------------- 1 | from modeltranslation.translator import register, TranslationOptions 2 | from blog.models import Post, Category 3 | 4 | 5 | @register(Category) 6 | class CategoryTranslationOptions(TranslationOptions): 7 | fields = ("title", "description", 'parent_category', 'is_active') 8 | 9 | 10 | @register(Post) 11 | class PostTranslationOptions(TranslationOptions): 12 | fields = ("title", "content", 'category','is_active') 13 | -------------------------------------------------------------------------------- /blog/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import path, include 2 | from blog import views 3 | 4 | app_name = 'blog' 5 | urlpatterns = [ 6 | path('', views.PostListView.as_view(), name='list'), 7 | path('create/', views.CreatePostView.as_view(), name='create'), 8 | path('