﻿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
34723	`TypeError` when loading a Django app with incorrect type of `choices`	Natalia Bidart	nobody	"While reviewing the PR for #31262, I was performing some local changes to ensure that the error messages shown by the check framework were accurate and correct, and I changed a `choices` definition to be just an int. This change made the reloader fail with an exception:

{{{
  File ""/home/nessita/fellowship/projectfromrepo/ticket_31262/models.py"", line 31, in <module>
    class OtherTestModelForm(forms.ModelForm):
  File ""/home/nessita/fellowship/django/django/forms/models.py"", line 308, in __new__
    fields = fields_for_model(
             ^^^^^^^^^^^^^^^^^
  File ""/home/nessita/fellowship/django/django/forms/models.py"", line 233, in fields_for_model
    formfield = f.formfield(**kwargs)
                ^^^^^^^^^^^^^^^^^^^^^
  File ""/home/nessita/fellowship/django/django/db/models/fields/__init__.py"", line 2384, in formfield
    return super().formfield(
           ^^^^^^^^^^^^^^^^^^
  File ""/home/nessita/fellowship/django/django/db/models/fields/__init__.py"", line 2136, in formfield
    return super().formfield(
           ^^^^^^^^^^^^^^^^^^
  File ""/home/nessita/fellowship/django/django/db/models/fields/__init__.py"", line 1112, in formfield
    defaults[""choices""] = self.get_choices(include_blank=include_blank)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ""/home/nessita/fellowship/django/django/db/models/fields/__init__.py"", line 1048, in get_choices
    choices = list(self.choices)
              ^^^^^^^^^^^^^^^^^^
TypeError: 'int' object is not iterable
}}}

I believe that the code in `Field.get_choices` could be a little more robust, so exceptions are not raised on incorrect choices type. Ideally we'd let the check framework run and report these issues is a friendlier manner."	Cleanup/optimization	closed	Database layer (models, ORM)	dev	Normal	wontfix			Unreviewed	0	0	0	0	0	0
