In the Django FAQ there's a suggestion for "How do I change the
attributes for a widget on a field in my model". The method given is

    def formfield_for_dbfield(self, db_field, **kwargs):
        # This method will turn all TextFields into giant TextFields
        if isinstance(db_field, models.TextField):
            return
forms.CharField(widget=forms.Textarea(attrs={'cols': 130, 'rows':30,
'class': 'docx'}))
        return super(MyOtherModelInline,
self).formfield_for_dbfield(db_field, **kwargs)

The example given is for admin.StackedInline, I've used it on a
admin.ModelAdmin. It works. (Changed MyOtherModelInline obviously).

However, if a TextField model field has a blank=True attribute, the
admin changes this to a required input when the above method is added
to the admin.

Just in case it was some dependency I was introducing by accident, I
went back and used the same on a TextField added to the tutorial
example in the docs. Same problem.

Have I got the method wrong somewhere?

This is on 1.2.1.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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