﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
27864	Limit the number of terms in an admin search	VINAY KUMAR SHARMA	nobody	"Found this bug when searching with long string:

OperationalError at /posts/posts

(1116, 'Too many tables; MySQL can only use 61 tables in a join')


{{{
Request URL: http://cms.example.com/posts/posts/?q=Deliverable++TRC+Promo+%282+Options%29+Visual+Snapshot++%28Montage%29+How+do+you+know+your+reward+Strategy+is+working%3F+Masterclass%3A+Consumerization+of+Total+Rewards%3A+Superhero%27s+Toolkit+Alignment%2C+Management+and+Governance+of+%E2%80%98Executive+Pay%E2%80%99+and+Long+Term+Incentives+Award+Ceremony%3A+League+Awards+-Total+Rewards+2017+%22Masterclass%3AMotivating+your+Internal+Customers++Part+II%3A+A+Communication+Toolkit+by+Preeti+Gupta%2C+Aditya+Birla+Group
}}}


I've created a CMS system using Django Admin, where models Posts is in app Posts.

Model Posts has an **M2M** field `authors`, and this field I've included in search for `admin.ModelAdmin`:

e.g here:

{{{
# models.py
@python_2_unicode_compatible
class Posts(models.Model):
    id = models.AutoField(primary_key=True, db_column='article_id')
    #
    # ... other fields ...
    #
    # Related M2M/Foreign Key fields
    authors = models.ManyToManyField(Author, through='PostAuthors',
                                     through_fields=('post', 'author'))
    subcategories = models.ManyToManyField(SubCategory, through='PostSubcategory',
                                           through_fields=('post', 'subcategory'))

# admin.py
@admin.register(Posts)
class PostsAdmin(admin.ModelAdmin):
    actions = [delete_selected, republish_selected, add_to_top_stories]
    list_per_page = ADMIN_LIST_PER_PAGE
    list_filter = [PostTypeListFilter, 'datetime', 'is_active', 'is_deleted']
    search_fields = ['authors__name', 'title']
}}}
"	Cleanup/optimization	closed	contrib.admin	1.8	Normal	wontfix	mysql		Unreviewed	0	0	0	0	0	0
