readonly and autofocus support in form fields?

43 views
Skip to first unread message

Norberto Bensa

unread,
Jan 18, 2017, 11:11:47 PM1/18/17
to django...@googlegroups.com
Hello,

I usually need to make form fields readonly or autofocus (the app I'm
developing right now has a lot of these).

While I can do it in the form or a custom field, I'm wondering why
there's no support for these attributes out-of-the-box (btw, there's
support for disabled).

TIA,
Norberto

jorr...@gmail.com

unread,
Jan 19, 2017, 5:11:52 AM1/19/17
to Django users
I think the problem here is with ModelForms. Where would you define these properties for ModelForms? Putting them in your Model classes doesn't make sense because it violates loose coupling between models and forms/templates. It's already quite peculiar that Model fields can have a blank=True attribute.

If you haven't already, look into django-crispy-forms. It gives you much more granular control over your forms while maintaining loose coupling and OO-syntax.
Reply all
Reply to author
Forward
0 new messages