Tim, this won’t help you to use or solve the formfield_overrides issues, but 
maybe it will be helpful. I’ve not tried this for a CharField, but it works 
great on a TextField (which has no max_length, so model size isn’t impacted):

1. Install  widget tweaks and add {% load widget_tweaks %} at the top of your 
HTML page.
2. On your HTML page, instantiate the field using this format: {{ 
form.notes|attr:"rows:20"|attr:"cols:50" }} - you can use either row/cols or 
both as in this case, and any char size.

Here’s a great usage example on widget tweaks: 
https://simpleisbetterthancomplex.com/2015/12/04/package-of-the-week-django-widget-tweaks.html.

I hope this is useful for you.

Jim Illback


On May 12, 2019, at 3:03 PM, Tim Johnson 
<t...@akwebsoft.com<mailto:t...@akwebsoft.com>> wrote:

* Joe Reitman <jreitma...@gmail.com<mailto:jreitma...@gmail.com>> [190512 
13:34]:
Tim,

I found this in the Django source code on Github searching for
'formfield_overrides'. It is in a test module testing formfield_overrides
functionality. I'm assuming you imported TextInput from forms? This should
work to change your *admin* display. Are trying to change your Admin panel
form or a form going out to the user?


class BandAdmin(admin.ModelAdmin):
formfield_overrides = {
CharField: {'widget': forms.TextInput(attrs={'size': '10'})}
}
 I am trying to change a form going to the user.
 The form in the admin page __does__ show the size attribute in
 the HTML source code for input/text.

 So it appears that formfield_overrides only affects the admin
 page.

 I'm going to call this solved - given that I can "widen" the field
 with css.

 Thanks again Joe. You've been a great help and I've learned a lot.
 cheers

--
Tim Johnson
http://www.tj49.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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20190512220300.GF2372%40mail.akwebsoft.com.
For more options, visit https://groups.google.com/d/optout.

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8AA27AC7-87A9-4857-BFD3-929386B4EEE2%40hotmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to