from:http://www.djangoproject.com/documentation/newforms/#widgets
class CommentForm(forms.Form): name = forms.CharField( widget=forms.TextInput(attrs={'class':'special'})) url = forms.URLField() comment = forms.CharField( widget=forms.TextInput(attrs={'size':'40'})) hth, -richard On 6/4/08, Wim Feijen <[EMAIL PROTECTED]> wrote: > > > Hello people, > > Being able to work with Django is very helpful to me. However, I am > unsure whether I can create a form out of a database model and then > customize that form. Using widgets to increase the textarea to 40 > would be great! But after reading the documentation I am convinced I > cannot do that. > > One solution I can think of, is to loop over the fields in the form > and start changing those? Is that possible? Then again, is that the > proper way to do it? > > My models are below. > > Thanks for any help! > > Wim > > ---- > > class Person(models.Model): > name = models.CharField(max_length=100) > notes = models.CharField(max_length=100, blank=True) > email = models.EmailField(max_length=100, blank=True) > cellphone = models.CharField(max_length=100, blank=True) > officephone = models.CharField(max_length=100, blank=True) > chat = models.CharField(max_length=100, blank=True) > skypename = models.CharField(max_length=100, blank=True) > street = models.CharField(max_length=100, blank=True) > number = models.CharField(max_length=100, blank=True) > suffix = models.CharField(max_length=100, blank=True) > zip = models.CharField(max_length=100, blank=True) > city = models.CharField(max_length=100, blank=True) > country = models.CharField(max_length=100, blank=True) > photo = models.ImageField(upload_to='.', blank=True) > company = models.ManyToManyField(Company) > groups = models.ManyToManyField(Group) > deleted = models.BooleanField(default=False) > shared = models.ManyToManyField(User, related_name='shared') > owner = models.ForeignKey(User) > > def __str__(self): > return self.name > > class PersonForm(ModelForm): > class Meta: > model = Person > fields = ['name', 'notes', 'email', 'cellphone', > 'officephone', 'skypename', 'street', 'number', 'suffix', 'zip', > 'city', 'country', 'photo'] > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---