Hi, I have this:
class SomeModel(models.Model): some_choice = models.CharField(maxlength=255, choices=CHOICES_DICT) And I'm generating a form for HTML display using this: SomeForm = newforms.models.form_for_model(SomeModel) form = SomeForm() But my some_choices field just shows up as a standard TextInput widget. I've tried overriding the widget using a custom callback, like this: def obj_callback(f, **kwargs): if f.name == "some_choice": kwargs['widget'] = newforms.Select() return f.formfield(**kwargs) SomeForm = newforms.models.form_for_model(SomeModel, formfield_callback = obj_callback) form = SomeForm() But as you would expect, this displays a Select widget, but it has no options. I've got a temporary workaround which does this: kwargs['widget'] = newforms.Select(choices=CHOICES_DICT) ...but it's not very DRY, and I'd really like to do away with the callback function completely, instead defining the data model where it belongs: in the model. My expectation was that the formfield would recognise the choices=CHOICES in my model and generate a widget accordingly, but it doesn't. Am I missing something here? Or is this worth a patch submission? Seems like I'm having to do a lot of hacking to get my forms displaying nicely, particularly when it comes to designating widgets for fields in a model. Any enlightenment much appreciated. -Phil --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---