Get a form Field for a database Field that has declared choices.
(self, db_field, request, **kwargs)
| 276 | return db_field.formfield(**kwargs) |
| 277 | |
| 278 | def formfield_for_choice_field(self, db_field, request, **kwargs): |
| 279 | """ |
| 280 | Get a form Field for a database Field that has declared choices. |
| 281 | """ |
| 282 | # If the field is named as a radio_field, use a RadioSelect |
| 283 | if db_field.name in self.radio_fields: |
| 284 | # Avoid stomping on custom widget/choices arguments. |
| 285 | if "widget" not in kwargs: |
| 286 | kwargs["widget"] = widgets.AdminRadioSelect( |
| 287 | attrs={ |
| 288 | "class": get_ul_class(self.radio_fields[db_field.name]), |
| 289 | } |
| 290 | ) |
| 291 | if "choices" not in kwargs: |
| 292 | kwargs["choices"] = db_field.get_choices( |
| 293 | include_blank=db_field.blank, blank_choice=[("", _("None"))] |
| 294 | ) |
| 295 | return db_field.formfield(**kwargs) |
| 296 | |
| 297 | def get_field_queryset(self, db, db_field, request): |
| 298 | """ |
no test coverage detected