On Mon, Apr 6, 2009 at 3:46 PM, grimmus <graham.col...@gmail.com> wrote:

>
> Thanks for the reply.
>
> I dont get an error anymore but nothing appears now, not even a
> textbox ! Please see my model below
>
> from django.db import models
> from django import forms
> from django.forms import ModelForm
>
> import datetime
>
> ENQUIRY_TYPES = (
>    ('Allergy Testing','Allergy Testing'),
>    ('Reflexology','Reflexology'),
>    ('Other','Other'),
> )
>
> class ContactEnquiry(models.Model):
>    name = models.CharField(max_length=100)
>    phone_number = models.CharField(max_length=100)
>    email_Address = models.EmailField()
>    what_are_you_interested_in = models.CharField
> (max_length=16,choices=ENQUIRY_TYPES)
>    enquiry = forms.CharField(widget=forms.Textarea)
>    enquiry_date = models.DateTimeField(auto_now_add=True)
>    replied = models.BooleanField(default=False)
>    def __unicode__(self):
>        return self.name
>
> class ContactForm(ModelForm):
>    class Meta:
>        model = ContactEnquiry
>        exclude = ('replied','enquiry_date')
>
>
> Any idea why the tetxtarea isnt appearing ?
>
> On Apr 6, 8:21 pm, Alex Gaynor <alex.gay...@gmail.com> wrote:
> > On Mon, Apr 6, 2009 at 2:04 PM, grimmus <graham.col...@gmail.com> wrote:
> >
> > > Hi,
> >
> > > I am trying to create a text area for a form that is generated through
> > > ModelForm.
> >
> > > The field i have is
> >
> > > enquiry = models.CharField(widget=models.Textarea)
> >
> > > but i get the error
> >
> > > 'module' object has no attribute 'Textarea'
> >
> > > I have tried a few variations but with no luck,
> >
> > > Any ideas ?
> >
> > > Thanks in advance
> >
> > Those are par tof the Django forms library, not the models library, so it
> > should look like:
> >
> > from django import forms
> >
> > forms.CharField(widget=forms.Textarea)
> >
> > Alex
> >
> > --
> > "I disapprove of what you say, but I will defend to the death your right
> to
> > say it." --Voltaire
> > "The people's good is the highest law."--Cicero
> >
>
You've put the form field on the model, instead of on the form, see
http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#overriding-the-default-field-typesfor
how it should work.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to