Django 3.0 Admin CHange Page Not Displaying Selected Option Correctly

13 views
Skip to first unread message

Mark Phillips

unread,
Mar 24, 2020, 12:03:40 PM3/24/20
to django users

I am running Django 3.0 and using Chrome Version 80.0.3987.132 (Official Build) (64-bit) and Firefox version 74 (64-bit). I have a select box on an admin change page for a model, and the correct value from the database is shown this way on the html source page generated by django:

<option value="228">Frank</option>

<option value="8" selected>Sam</option>

<option value="19">Henry</option>

However, the page is displayed in both browsers, Chrome and Firefox, with the default value "Pick one of the people", as if nothing has been selected. If I select another value from the drop down list, it is correctly inserted into the database, but the html on the admin change page still does not have selected="selected" in the correct option, but just the word 'selected' as shown above.

I was looking online at the correct way to select an option in an option list, and it seems the correct (X)HTML way is to use selected="selected" in the option tag. Why is Django generating the old HTML way with just the word 'selected' in the option tag? Is there a way to fix this, or is this a bug in django or my browsers?

I am not using any javascript or css on this select box. Just plain vanilla django 3.0 reading a value from the database for the admin change page. Not my page template, but plain vanilla django admin templates.

Thanks!

Mark

Reply all
Reply to author
Forward
0 new messages