# 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




class BlogTable(tables.Table):
    title_i18n = tables.LinkColumn("blog_detail", args=(tables.A("pk"),))
    edit = tables.TemplateColumn(
        template_code="""<a href="{% url 'blog-edit' pk=record.pk %}" class="btn btn-sm btn-primary">edit</a>""",
        empty_values=(),
        orderable=False,
        verbose_name="edit",
    )

    class Meta:

# 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





class BlogTable(tables.Table):
    title_i18n = tables.LinkColumn("blog_detail", args=(tables.A("pk"),))
    edit = tables.TemplateColumn(
        template_code="""<a href="{% url 'blog-edit' pk=record.pk %}" class="btn btn-sm btn-primary">edit</a>""",
        empty_values=(),
        orderable=False,
        verbose_name="edit",
    )

    class Meta:

        model = Blog