Monday, January 6, 2020

Re: Override value of a TextField class method.

Easy. You need to provide attrs as dict to the new object. 

Le lun. 6 jan. 2020 à 21:36, Fabio da Silva Pedro <fabio.silvapedro@gmail.com> a écrit :
Hi everyone!

this is an excerpt line from my model

observacoes = models.TextField(null=True, blank=True, verbose_name='Informações complementares')

How i do override a field type TextField and change your internal class value Textarea, this is a widget from TextField Class and override this method below:

def __init__(self, attrs=None):
# Use slightly better defaults than HTML's 20x2 box
default_attrs = {'cols': '40', 'rows': '10'}
if attrs:
default_attrs.update(attrs)
super().__init__(default_attrs)

I need change value from default_attrs = {'rows':'10'} for {'rows':'4'} 

 How can I override this in my model or in my view?

Thanks for watching!

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/adef9112-df5b-4b03-9861-97d1495dd00b%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAJenkLDF5My0GH3mFdCPftEq%3DeH0Mep4O83jPK4OY0Tj8Jk5LQ%40mail.gmail.com.

No comments:

Post a Comment