On Wed, Jun 18, 2008 at 4:53 PM, Huuuze <[EMAIL PROTECTED]> wrote:

>
> I have the following model:
>
> class Publishers(models.Model):
>  books = models.CharField(maxlength=1, choices=BOOKS)
>
> BOOKS is a tuple:
> BOOKS = ( ('1', 'Book A'), ('2', 'Book B') )
>
> When I use form_for_instance(Publishers) to generate my template's
> HTML based upon the Publisher model, the books field is a standard
> <input> field rather than a <select> field.
>

You aren't actually passing the Publishers model to form_for_instance, are
you?  That wouldn't work, you must be passing a Publishers model instance?
Or are you using form_for_model?

Is this a bug in Django or am I missing something?  If its th latter,
> how can I get the desired effect using my model (I realize I could
> create a custom form by coding a PublisherForm(forms.Form) -- trying
> to stay DRY).  From my perspective, it seems reasonable to expect the
> HTML to be a <select> field when a "choices" attribute is added to the
> model definition.


I just tried this with a similar model and a recent trunk checkout and
form_for_instance generated a select input for the field with choices, as
you would expect, so something is going awry with what you are doing.  I
can't really guess what, though, based on the information you provided.

What version of Django are you using?  Is there a reason you are using the
older form_for_ methods instead of the newer (and preferred) ModelForms?

Karen

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to