Why does ModelForm do validation and not Model

2019-04-16 Thread Will Gordon
I can't seem to find a good reason for this. And I could foresee this 
preventing potential mistakes. I'm not proposing to actually change the 
implementation, I guess I'm just looking for the reason of it.

-- 
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/97ae2f12-bc27-403d-8b76-f456a63fc0d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why does ModelForm do validation and not Model

2019-04-16 Thread Will Gordon
So the validation is cheaper when performed by ModelForm, as opposed to the 
Model?

-- 
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/8d929b8e-b0e9-4a88-b796-26f00266f729%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why does ModelForm do validation and not Model

2019-04-16 Thread Will Gordon
Ahh, cool. That makes more sense. I worry that it still leaves open the 
potential of accidentally not validating something. It may make more sense 
to offer instance.save(validate=False) instead of relying on the developer 
to always know whether they can trust the input. But I agree that for 
historical reasons, I'm sure it's much more difficult to implement this now.

-- 
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/cd8ba920-f59d-4afc-afe7-7988fb3348a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Force "required" fields to be included in a ModelForm

2019-04-16 Thread Will Gordon
In the same way that editable fields are forced to not be included in a 
ModelForm (
https://github.com/django/django/blob/master/django/forms/models.py#L146), 
I would like to propose that "required" fields (`blank=False`) be forced to 
be included in a ModelForm.

While I understand that a developer can force this inclusion themselves, 
but on a large project, it should not be necessary to always ensure that a 
Model and ModelForm are in sync.

Since this is probably a non-trivial patch (
https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/submitting-patches/#non-trivial-patches)
 
I need to provide evidence that this has been discussed. As such, I'm open 
to any and all opinions!

-- 
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/980d8112-d51c-4e88-a17f-5e9a4a3577d2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Force "required" fields to be included in a ModelForm

2019-04-16 Thread Will Gordon
Sorry if I wasn't more clear, but using a warning was exactly what I was 
proposing. In the same way that a FieldError is raised when an editable field 
is listed in fields, I was essentially planning on doing the exact same 
check on the blank attribute. I agree that this should be ignorable, and 
I'm not sure that I've settled on a way to do that as of yet.

-- 
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/5e34c24e-513b-42fd-889b-993e2b083a5e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Force "required" fields to be included in a ModelForm

2019-04-16 Thread Will Gordon
I can certainly agree that there may be some use cases where it should be 
possible to disable this functionality, but I would argue that erroring on 
a missing, required field should be the default, and allow for a way to 
override...as opposed to allowing missing fields and requiring a workaround 
to ensure they're not missing.

-- 
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/7ab66349-f1e2-4f49-9015-e55761fc8682%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Force "required" fields to be included in a ModelForm

2019-04-16 Thread Will Gordon
Would it be weird to just make it so that the "required" field *must* be 
present in exclude? This way, if you *accidentally* leave off a required 
field, you're quickly notified about itbut if you explicitly mark it as 
something to exclude, it makes it clear to everyone exactly what you're 
trying to do? The whole "explicit is better than implicit" and what not.

-- 
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/c0b7e5d5-f422-42be-ace8-c0201a2f79a7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Force "required" fields to be included in a ModelForm

2019-04-17 Thread Will Gordon
Well shoot...this definitely seems like something only I'm running into. 
Appreciate y'alls feedback. Thanks 👍🏻

-- 
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/d024a7bd-b0c6-48ef-ad54-0e4f473757a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.