from django.contrib import admin
from blog.models import Post, Category, Tag, Comment
def tag_list(obj):
return ','.join([t.name for t in obj.tags.all()])
@admin.register(Post)
class PostAdmin(admin.ModelAdmin):
list_display = ('id', 'category', 'tags', 'description', 'image', 'create_dt', 'update_dt', 'like')
def get_queryset(self, request):
return super().get_queryset(request).prefetch_related('tags')
@admin.register(Category)
class CategoryAdmin(admin.ModelAdmin):
list_display = ('id', 'name', 'description')
@admin.register(Tag)
class TagAdmin(admin.ModelAdmin):
list_display = ('id', 'name')
@admin.register(Comment)
class CommentAdmin(admin.ModelAdmin):
list_display = ('id', 'post', 'short_content', 'create_dt', 'update_dt')
코드는 맞는데요
이런오류가떠요
python manage.py makemigrations blog 실행하면
<class 'blog.admin.PostAdmin'>: (admin.E109) The value of 'list_display[2]' must not be a ManyToManyField.
PS C:\Users\qnzjn\VueDjAgency> python manage.py makemigrations blog
SystemCheckError: System check identified some issues:
이런 오류가 뜨네요