Regarding django-select2: I don’t want to provide fields at this point. Django has the concept of widgets, and that is all I need for select2. You could overwrite the widget for all forms with a template processor, but why? You’d need to know which db columns you need too search to filter the query set, but in some cases you use a full text index or even elastic search. Besides, django-select2 started with fields and we moved it to widgets, just to reduce the code base and complexity. After all, you need to maintain all that code. I wouldn’t introduce too much magic (pep20). We made the field definition in ModelForms mandatory and a lot of other “assumptions” have been deleted in recent releases.
> On Mar 9 2016, at 3:26 pm, James Pic <james...@gmail.com> wrote: > > On Wed, Mar 9, 2016 at 3:09 PM, Johannes Hoppe <i...@johanneshoppe.com> wrote: > We'll you can change the `default` form Field using > `django.db.models.Field.formfield`. > > Do you mean that, for example, an app like django-select2 could provide the following model fields ? > > \- Select2WidgetForeignKey, \- Select2WidgetOneToOneField, \- Select2MultipleWidgetManyToManyField, \- HeavySelect2WidgetForeignKey, \- HeavySelect2WidgetOneToOneField, \- HeavySelect2MultipleWidgetManyToManyField > > Also, wouldn't that require overriding the complete model class to change the default widget for an external app ? > > Also, would it be possible to conditionally enable Select2 widgets depending whether select2 is in INSTALLED_APPS without changing the model class ? > > Or perhaps everybody would benefit from changing these hardcoded values into attributes ? > > > But that is actually the thing I don't like I think this needs to go: > https://github.com/django/django/blob/d5f89ff6e873dbb2890ed05ce2aeae62879 2c8f7/django/db/models/fields/__init__.py#L869-L905 > > If that goes, so should save_form_data and value_from_object, that's the first option I was talking about. I think we can still do that later. Changing the hardcoded defaults into instance attributes would still be useful when we do that. > > > > But at the end, I don't have a particular pain with all that. You can easily > write your own model form, that changes the behavior. If you feel like > changing it, go ahead, but I would welcome a removing the cross dependency. > > There's got to be code that couples db fields and form fields, perhaps it would help to move it around, but we'll also have to change it. > > Again, I think both solutions are good here: we don't have to choose one or another. When have the opportunity to do one before the other, which benefits to django's stability because moving .formfield() outside the model field is going to cause a lot of BC breaks in apps and projects. > > Thanks for sharing a bit of your time ! > > Best > > \-- <http://yourlabs.org> Customer is king - Le client est roi - El cliente es rey. > > \-- You received this message because you are subscribed to a topic in the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this topic, visit https://groups.google.com/d/topic /django-developers/zG-JvS_opi4/unsubscribe. To unsubscribe from this group and all its topics, send an email to django- developers+unsubscr...@googlegroups.com. To post to this group, send email to django-developers@googlegroups.com. Visit this group at https://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid /django-developers/CALC3KadmQM6TmKsabD3yf5_r5cqa0JiEe%2BHZph8reTRe0iO%2BCg%40m ail.gmail.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To post to this group, send email to django-developers@googlegroups.com. Visit this group at https://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/a2cempdctyubtm9n4v815dwh1-0%40mailer.nylas.com. For more options, visit https://groups.google.com/d/optout.