Override value of a TextField class method.

2020-01-06 Thread Fabio da Silva Pedro
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+unsubscr...@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.


Re: Override value of a TextField class method.

2020-01-06 Thread Fabio da Silva Pedro
>
> Easy. You need to provide attrs as dict to the new object.
>
>
Ok, I thought about that too, but I don't know how to do it, I copied the
whole method and pasted it into my model and tried to access its
superclass, but I didn't get it!
Maybe I'm doing something wrong yet.

Would you have any examples for me?

I can easily do this with jQuery, but I want to learn how to do this using
just Django and for that I still have little experience in method override.

best regards!

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGE5jT83u5wahCwwzfF2b0td_MzEgj9L-DV4e9DZH8mcWq7G0Q%40mail.gmail.com.


Re: Override value of a TextField class method.

2020-01-07 Thread Fabio da Silva Pedro
OK, thank's for this!

Em ter., 7 de jan. de 2020 às 03:03, Mohamed A  escreveu:

> Hint:.. __init__ is a constructor not any method.
>
> Le lun. 6 jan. 2020 à 23:02, Fabio da Silva Pedro <
> fabio.silvape...@gmail.com> a écrit :
>
>> Easy. You need to provide attrs as dict to the new object.
>>>
>>>
>> Ok, I thought about that too, but I don't know how to do it, I copied the
>> whole method and pasted it into my model and tried to access its
>> superclass, but I didn't get it!
>> Maybe I'm doing something wrong yet.
>>
>> Would you have any examples for me?
>>
>> I can easily do this with jQuery, but I want to learn how to do this
>> using just Django and for that I still have little experience in method
>> override.
>>
>> best regards!
>>
>> --
>> 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+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAGE5jT83u5wahCwwzfF2b0td_MzEgj9L-DV4e9DZH8mcWq7G0Q%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAGE5jT83u5wahCwwzfF2b0td_MzEgj9L-DV4e9DZH8mcWq7G0Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAJenkLCaqXO15urag46XLKzpOoNwbzOay5H1n-Pn3NovhssL%3DA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAJenkLCaqXO15urag46XLKzpOoNwbzOay5H1n-Pn3NovhssL%3DA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>


-- 
*Fábio S. Pedro*
(21) 97569-7573(WhatsApp).

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGE5jT9rB5K%2BZF8mSeU%3DeWdOd%3D6SUdde3BZqO%3Drct4h2jAL5jw%40mail.gmail.com.