#28716 closed Bug (fixed)

search_fields = ['question_text'] from Tutorial07 not working.

Reported by: Patrick Kyne Owned by: Patrick Kyne
Component: Documentation Version: 1.11
Severity: Normal Keywords: search_fields documentation tutorial
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Patrick Kyne)

Following the django tutorial from the beginning, everything works as it should except the Search Fields example in Tutorial 07.

Following the tutorial, my polls/admin.py appears below. However, no search field appears in Google Chrome or in Firefox. No error is thrown by the django server either. I did not find any relevant google responses to the issue, nor did I find it here in Trac.

## polls/admin.py:
from django.contrib import admin

# Register your models here.

from .models import Question, Choice

class ChoiceInline(admin.TabularInline):
    model = Choice
    extra = 3

class QuestionAdmin(admin.ModelAdmin):
    fieldsets = [
        (None,               {'fields': ['question_text']}),
        ('Date information', {'fields': ['pub_date'], 'classes': ['collapse']}),
    inlines = [ChoiceInline]

    list_display = ('question_text', 'pub_date', 'was_published_recently')

    list_filter = ['pub_date']

    search_fields = ['question_text']

admin.site.register(Question, QuestionAdmin)

System check identified no issues (0 silenced).
October 16, 2017 - 15:36:08
Django version 1.11.5, using settings 'mysite.settings'
Starting development server at

{140}$ python
Python 3.6.2 (default, Aug 03 2017, 16:34:42) [GCC] on linux

Attachments (1)

Screenshot_20171016_172927.png (64.7 KB) - added by Patrick Kyne 22 months ago.
Chrome example

Download all attachments as: .zip

Change History (4)

Changed 22 months ago by Patrick Kyne

Chrome example

comment:1 Changed 22 months ago by Patrick Kyne

Description: modified (diff)

I've tested it with both the search_fields as:

search_fields = ['question_text']


search_fields = ['question_text', 'pub_date']

to see if there were any difference or error thrown. No difference. No search field is displayed, and no error is thrown.

comment:2 Changed 22 months ago by Patrick Kyne

Owner: changed from nobody to Patrick Kyne
Status: newassigned

For the search_field to show up in the Admin website, all that was needed was to stop (Ctrl-C) and restart the django test server. Then the search field shows up as desired.

Perhaps the documentation should be updated to state this.

comment:3 Changed 22 months ago by Patrick Kyne

Resolution: fixed
Status: assignedclosed

For the Search box to appear on the Admin website (and the search_fields to function) a stop and restart of the django test server was required.


? python manage.py runserver

After that, the search box appeared and functioned as desired.

Perhaps the on-line tutorial should be updated to reflect this.


Note: See TracTickets for help on using tickets.
Back to Top