Prefetch tags in articles admin
This commit is contained in:
parent
b5f3331386
commit
d53ac1ef7a
1 changed files with 6 additions and 0 deletions
|
@ -71,6 +71,12 @@ class ArticleAdmin(admin.ModelAdmin):
|
|||
change_form_template = "articles/article_change_form.html"
|
||||
search_fields = ["title", "content", "tags__name"]
|
||||
autocomplete_fields = ["tags"]
|
||||
show_full_result_count = False
|
||||
|
||||
def get_queryset(self, request):
|
||||
queryset = super().get_queryset(request)
|
||||
queryset = queryset.prefetch_related("tags")
|
||||
return queryset
|
||||
|
||||
def publish(self, request, queryset):
|
||||
if not request.user.has_perm("articles.change_article"):
|
||||
|
|
Reference in a new issue