from django.contrib import admin
from django.contrib.contenttypes.admin import GenericStackedInline

from ugc.models import Post
from like.models import Like


class LikeInline(GenericStackedInline):
    ct_field = 'target_type'
    ct_fk_field = 'target_id'
    model = Like
    max_num = 1


class PostAdmin(admin.ModelAdmin):
    list_display = ('author', 'short_text', 'updated_at')
    inlines = [
        LikeInline
    ]

    def short_text(self, post):
        return post.text[:30]


admin.site.register(Post, PostAdmin)



71367cba6609ba522f4433c4540c3b7270de6ee5
<mask token>


class LikeInline(GenericStackedInline):
    <mask token>
    <mask token>
    <mask token>
    <mask token>


class PostAdmin(admin.ModelAdmin):
    list_display = 'author', 'short_text', 'updated_at'
    inlines = [LikeInline]

    def short_text(self, post):
        return post.text[:30]


<mask token>

<mask token>


class LikeInline(GenericStackedInline):
    ct_field = 'target_type'
    ct_fk_field = 'target_id'
    model = Like
    max_num = 1


class PostAdmin(admin.ModelAdmin):
    list_display = 'author', 'short_text', 'updated_at'
    inlines = [LikeInline]

    def short_text(self, post):
        return post.text[:30]


<mask token>

<mask token>


class LikeInline(GenericStackedInline):
    ct_field = 'target_type'
    ct_fk_field = 'target_id'
    model = Like
    max_num = 1


class PostAdmin(admin.ModelAdmin):
    list_display = 'author', 'short_text', 'updated_at'
    inlines = [LikeInline]

    def short_text(self, post):
        return post.text[:30]


admin.site.register(Post, PostAdmin)

from django.contrib import admin
from django.contrib.contenttypes.admin import GenericStackedInline
from ugc.models import Post
from like.models import Like


class LikeInline(GenericStackedInline):
    ct_field = 'target_type'
    ct_fk_field = 'target_id'
    model = Like
    max_num = 1


class PostAdmin(admin.ModelAdmin):
    list_display = 'author', 'short_text', 'updated_at'
    inlines = [LikeInline]

    def short_text(self, post):
        return post.text[:30]


admin.site.register(Post, PostAdmin)

from django.contrib import admin
from django.contrib.contenttypes.admin import GenericStackedInline

from ugc.models import Post
from like.models import Like


class LikeInline(GenericStackedInline):
    ct_field = 'target_type'
    ct_fk_field = 'target_id'
    model = Like
    max_num = 1


class PostAdmin(admin.ModelAdmin):
    list_display = ('author', 'short_text', 'updated_at')
    inlines = [
        LikeInline
    ]

    def short_text(self, post):
        return post.text[:30]


admin.site.register(Post, PostAdmin)


