# Path: example/app/models.py
# class Blog(models.Model):
#     title = models.CharField(max_length=255)
#     body = models.TextField(null=True, blank=True)
# 
#     category = models.ForeignKey(Category, null=True, blank=True, on_delete=models.CASCADE)
# 
#     i18n = TranslationField(fields=("title", "body"))
# 
#     class Meta:
#         indexes = [GinIndex(fields=["i18n"])]
# 
#     def __str__(self):
#         return self.title_i18n
# 
#     def get_absolute_url(self):
#         return reverse("blog_detail", args=(self.pk,))
# 
# class Category(models.Model):
#     name = models.CharField(max_length=255)
# 
#     i18n = TranslationField(fields=("name",))
# 
#     class Meta:
#         indexes = [GinIndex(fields=["i18n"])]
#         verbose_name_plural = "categories"
# 
#     def __str__(self):
#         return self.name_i18n


import json
import django_tables2 as tables
from django.shortcuts import redirect
from django.views.generic import DetailView
from django.views.generic.edit import UpdateView
from django_filters import FilterSet
from django_filters.views import FilterView
from .models import Blog, Category
    table_class = BlogTable
    model = Blog
    template_name = "table.html"


class FilteredBlogListView(FilterView, tables.SingleTableView):
    table_class = BlogTable
    model = Blog
    template_name = "table.html"

    filterset_class = BlogFilter


class BlogView(DetailView):
    model = Blog
    template_name = "blog.html"


class BlogUpdateView(UpdateView):
    model = Blog
    fields = ["title_en", "title_i18n", "body_en", "body_i18n", "category"]
    template_name = "blog_update_form.html"
    template_name_suffix = "_update_form"

    # success_url = reverse_lazy('blogs')


def fixtures(request):

    Blog.objects.all().delete()

# Path: example/app/models.py
# class Blog(models.Model):
#     title = models.CharField(max_length=255)
#     body = models.TextField(null=True, blank=True)
# 
#     category = models.ForeignKey(Category, null=True, blank=True, on_delete=models.CASCADE)
# 
#     i18n = TranslationField(fields=("title", "body"))
# 
#     class Meta:
#         indexes = [GinIndex(fields=["i18n"])]
# 
#     def __str__(self):
#         return self.title_i18n
# 
#     def get_absolute_url(self):
#         return reverse("blog_detail", args=(self.pk,))
# 
# class Category(models.Model):
#     name = models.CharField(max_length=255)
# 
#     i18n = TranslationField(fields=("name",))
# 
#     class Meta:
#         indexes = [GinIndex(fields=["i18n"])]
#         verbose_name_plural = "categories"
# 
#     def __str__(self):
#         return self.name_i18n


# Path: example/app/views.py
import json
import django_tables2 as tables
from django.shortcuts import redirect
from django.views.generic import DetailView
from django.views.generic.edit import UpdateView
from django_filters import FilterSet
from django_filters.views import FilterView
from .models import Blog, Category

    table_class = BlogTable
    model = Blog
    template_name = "table.html"


class FilteredBlogListView(FilterView, tables.SingleTableView):
    table_class = BlogTable
    model = Blog
    template_name = "table.html"

    filterset_class = BlogFilter


class BlogView(DetailView):
    model = Blog
    template_name = "blog.html"


class BlogUpdateView(UpdateView):
    model = Blog
    fields = ["title_en", "title_i18n", "body_en", "body_i18n", "category"]
    template_name = "blog_update_form.html"
    template_name_suffix = "_update_form"

    # success_url = reverse_lazy('blogs')


def fixtures(request):

    Blog.objects.all().delete()

    Category.objects.all().delete()