Skip to content

Instantly share code, notes, and snippets.

@alexpirine
Created October 20, 2016 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexpirine/67f97c48d0b0c24182c3078ac0584fc2 to your computer and use it in GitHub Desktop.
Save alexpirine/67f97c48d0b0c24182c3078ac0584fc2 to your computer and use it in GitHub Desktop.
Django's ModelChoiceField with empty_label generates an invalid <select>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Test</title>
</head>
<body>
<select id="id_some_field" name="some_field" required>
<option value="1">Value 1</option>
<option value="2">Value 2</option>
<option value="3">Value 3</option>
<!-- ... -->
</select>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment