Re: [Django] #25417: Add a system check for an invalid default on a model field

2017-01-04 Thread Django
#25417: Add a system check for an invalid default on a model field
-+-
 Reporter:  André Avorio |Owner:  Simon
 |  Charette
 Type:  New feature  |   Status:  closed
Component:  Core (System |  Version:  master
  checks)|
 Severity:  Normal   |   Resolution:  fixed
 Keywords:  decimal, | Triage Stage:  Ready for
  InvalidOperation, migrations   |  checkin
Has patch:  1|  Needs documentation:  1
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Tim Graham):

 I closed #27684 as a duplicate. It's a similar problem where a string
 (rather than `date`) was incorrectly assigned as the default for
 `DateField`.

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.796333d8e91ebba1ecfd8a1c30dbee14%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #25417: Add a system check for an invalid default on a model field

2017-01-04 Thread Django
#25417: Add a system check for an invalid default on a model field
-+-
 Reporter:  André Avorio |Owner:  Simon
 |  Charette
 Type:  New feature  |   Status:  closed
Component:  Core (System |  Version:  master
  checks)|
 Severity:  Normal   |   Resolution:  fixed
 Keywords:  decimal, | Triage Stage:  Ready for
  InvalidOperation, migrations   |  checkin
Has patch:  1|  Needs documentation:  1
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Tim Graham):

 The decision to revert this was discussed on
 [https://groups.google.com/d/topic/django-
 developers/-E3b5DCtEp0/discussion django-developers].

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.98ed984322d9493201e6d33d91a9d7a2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #25417: Add a system check for an invalid default on a model field

2015-11-07 Thread Django
#25417: Add a system check for an invalid default on a model field
-+-
 Reporter:  avorio   |Owner:  charettes
 Type:  New feature  |   Status:  closed
Component:  Core (System |  Version:  master
  checks)|
 Severity:  Normal   |   Resolution:  fixed
 Keywords:  decimal, | Triage Stage:  Ready for
  InvalidOperation, migrations   |  checkin
Has patch:  1|  Needs documentation:  1
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-

Comment (by aidanlister):

 Yeah 71ebcb8 seems naive. Trying to validate the default value causes
 exceptions under certain scenarios, which means more than just a warning,
 it prevents the initial migrations from being run. The default value might
 only be valid after migrations are finished, e.g.:

 a) dynamic default values that rely on the database, e.g.:
 ref = models.CharField(unique=True, max_length=200,
 default=rectification_sequence_current, blank=True)

 rectification_sequence_current is a method that checks the sequence in the
 database. This throws as uncaught exception that the table doesn't exist.

 b) defaults that rely on a migration creating a row, e.g:
   pricetier = models.ForeignKey('PriceTier', default=0)

 the initial pricetier is created by the first migration, but that won't
 run, because the check does a database query against a table that doesn't
 exist.

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.19948598fbf134272bbe3b468dfaf0a2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #25417: Add a system check for an invalid default on a model field

2015-11-04 Thread Django
#25417: Add a system check for an invalid default on a model field
-+-
 Reporter:  avorio   |Owner:  charettes
 Type:  New feature  |   Status:  closed
Component:  Core (System |  Version:  master
  checks)|
 Severity:  Normal   |   Resolution:  fixed
 Keywords:  decimal, | Triage Stage:  Ready for
  InvalidOperation, migrations   |  checkin
Has patch:  1|  Needs documentation:  1
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-

Comment (by andialbrecht):

 Just FTR, I'm not totally sure if this is a valid use case, but for me
 this check (as published in Django 1.9 Beta 1) resulted in an error when
 running "manage.py check" or "manage.py migrate" on an empty database,
 when a model A defines a ForeignKey field to model B where the default is
 a certain value from the model B table. As in Django 1.9b1 the check tried
 to fetch the model B object from the still empty database, resulting in a
 "table does not exist" error.

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.c294d664a3d378a04a02f37b5e1cc2ea%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #25417: Add a system check for an invalid default on a model field

2015-10-28 Thread Django
#25417: Add a system check for an invalid default on a model field
-+-
 Reporter:  avorio   |Owner:  charettes
 Type:  New feature  |   Status:  closed
Component:  Core (System |  Version:  master
  checks)|
 Severity:  Normal   |   Resolution:  fixed
 Keywords:  decimal, | Triage Stage:  Ready for
  InvalidOperation, migrations   |  checkin
Has patch:  1|  Needs documentation:  1
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-

Comment (by timgraham):

 See #25628 for another issue in case this check is revisited.

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.b0cf24212bd59fea767982e47455c57a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #25417: Add a system check for an invalid default on a model field

2015-10-27 Thread Django
#25417: Add a system check for an invalid default on a model field
-+-
 Reporter:  avorio   |Owner:  charettes
 Type:  New feature  |   Status:  closed
Component:  Core (System |  Version:  master
  checks)|
 Severity:  Normal   |   Resolution:  fixed
 Keywords:  decimal, | Triage Stage:  Ready for
  InvalidOperation, migrations   |  checkin
Has patch:  1|  Needs documentation:  1
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Simon Charette ):

 In [changeset:"da9e9484f2407ea5f2309ba1899fc93c58d206e3" da9e9484]:
 {{{
 #!CommitTicketReference repository=""
 revision="da9e9484f2407ea5f2309ba1899fc93c58d206e3"
 [1.9.x] Revert "Fixed #25417 -- Added a field check for invalid default
 values."

 This reverts commit 71ebcb85b931f43865df5b322b2cf06d3da23f69.

 Backport of 976bd519a879b2fd7a356cb21bde32696adb545f from master
 }}}

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.40d8be9e7e6b215ac6d19105bb06b144%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #25417: Add a system check for an invalid default on a model field

2015-10-27 Thread Django
#25417: Add a system check for an invalid default on a model field
-+-
 Reporter:  avorio   |Owner:  charettes
 Type:  New feature  |   Status:  closed
Component:  Core (System |  Version:  master
  checks)|
 Severity:  Normal   |   Resolution:  fixed
 Keywords:  decimal, | Triage Stage:  Ready for
  InvalidOperation, migrations   |  checkin
Has patch:  1|  Needs documentation:  1
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Simon Charette ):

 In [changeset:"976bd519a879b2fd7a356cb21bde32696adb545f" 976bd519]:
 {{{
 #!CommitTicketReference repository=""
 revision="976bd519a879b2fd7a356cb21bde32696adb545f"
 Revert "Fixed #25417 -- Added a field check for invalid default values."

 This reverts commit 71ebcb85b931f43865df5b322b2cf06d3da23f69.
 }}}

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.4f293c0e6d97a24c6a602a1d0799922a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #25417: Add a system check for an invalid default on a model field

2015-10-21 Thread Django
#25417: Add a system check for an invalid default on a model field
-+-
 Reporter:  avorio   |Owner:  charettes
 Type:  New feature  |   Status:  closed
Component:  Core (System |  Version:  master
  checks)|
 Severity:  Normal   |   Resolution:  fixed
 Keywords:  decimal, | Triage Stage:  Ready for
  InvalidOperation, migrations   |  checkin
Has patch:  1|  Needs documentation:  1
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-

Comment (by charettes):

 > I'll also note that this isn't even the first time I've had to work
 around a buggy, overzealous, or plain wrong system check.

 The system check is a still a ''new'' component of Django and from the
 feedback we've had so far I think the prevention of misconfiguration and
 footguns outweigh the nuisance caused by some initial bugs and required
 adjustments.

 While I could be convinced we should remove or downgrade this check to a
 warning your actual use case doesn't convince me it's worth it. I still
 think this check is not buggy, overzealous nor plain wrong but that it's
 your use case that is bug prone.

 As Tim suggested I think gathering feedback from the developpers mailing
 list could help your case here.

 In the meantime if want to work around this check you can override the
 `check()` method of your reusable field to filter out `'fields.E008'`
 errors.

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.9c3daca4411d03f696fc90c11c071cbb%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #25417: Add a system check for an invalid default on a model field

2015-10-21 Thread Django
#25417: Add a system check for an invalid default on a model field
-+-
 Reporter:  avorio   |Owner:  charettes
 Type:  New feature  |   Status:  closed
Component:  Core (System |  Version:  master
  checks)|
 Severity:  Normal   |   Resolution:  fixed
 Keywords:  decimal, | Triage Stage:  Ready for
  InvalidOperation, migrations   |  checkin
Has patch:  1|  Needs documentation:  1
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-

Comment (by gavinwahl):

 > Do you have any problem adding this check to SILENCED_SYSTEM_CHECKS?

 Yes. This is in a reusable app. I can't make my users silence the check in
 order to use it.

 > That's not true, there's a whole ​documented layer of model validation.

 This validation is only used when called explicitly or when using a
 ModelForm. I expect a validation error from an initial value only to be
 raised if I ask if the model is valid.

 > I'm not entirely sure I understand your use case but wouldn't this
 special handling belong at the form level anyway?

 I need to be able to create the model instances without a form. A form is
 only used later, when the user is ready to edit the object. The initial
 object is created without user interaction.

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.1cddb5fdb7377d14869a09e482098ea6%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #25417: Add a system check for an invalid default on a model field

2015-10-17 Thread Django
#25417: Add a system check for an invalid default on a model field
-+-
 Reporter:  avorio   |Owner:  charettes
 Type:  New feature  |   Status:  closed
Component:  Core (System |  Version:  master
  checks)|
 Severity:  Normal   |   Resolution:  fixed
 Keywords:  decimal, | Triage Stage:  Ready for
  InvalidOperation, migrations   |  checkin
Has patch:  1|  Needs documentation:  1
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by timgraham):

 * status:  new => closed
 * resolution:   => fixed


--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.d725ff26925517d9087da91545577c83%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #25417: Add a system check for an invalid default on a model field

2015-10-16 Thread Django
#25417: Add a system check for an invalid default on a model field
-+-
 Reporter:  avorio   |Owner:  charettes
 Type:  New feature  |   Status:  new
Component:  Core (System |  Version:  master
  checks)|
 Severity:  Normal   |   Resolution:
 Keywords:  decimal, | Triage Stage:  Ready for
  InvalidOperation, migrations   |  checkin
Has patch:  1|  Needs documentation:  1
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-

Comment (by charettes):

 > Validation in Django only happens through forms, and is bypassed when
 manipulating a model directly.

 That's not true, there's a whole
 [https://docs.djangoproject.com/en/1.8/ref/models/instances/#validating-
 objects documented layer of model validation].

 > The precedent in Django is to allow creation of models that don't
 actually validate.

 You can still create model instances that don't validate and even save
 them if you'd like. The only thing that changed here is that you cannot
 tell Django to assign an invalid default value at instantiation time.

 > I use fields with `blank=False, default=''` to create a model with empty
 content that's only validated when a user edits it through a form.

 I'm not entirely sure I understand your use case but wouldn't this special
 handling belong at the form level anyway? I think the whole point of the
 separation of concerns between the model and the form layer is to be able
 to have enough flexibility at this level.

 > I don't understand how this is a Django bug at all. The opener of the
 bug is doing something wrong with Decimals, and got a
 decimal.InvalidOperation error. That seems like what should happen.

 The whole point of model field checks is to prevent you from doing the
 wrong thing by mistake and confirm you know what you are doing by
 silencing false positives.

 #25480 is an example where a simple configuration mistake was caught by
 this check.

 Like Tim said you can silence this check if you want to rely on having a
 `blank=False, default=''` field but don't be surprised if something breaks
 in Django further down the road.

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.8253e4d7b28ad7b742071a218d84e05e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #25417: Add a system check for an invalid default on a model field

2015-10-16 Thread Django
#25417: Add a system check for an invalid default on a model field
-+-
 Reporter:  avorio   |Owner:  charettes
 Type:  New feature  |   Status:  new
Component:  Core (System |  Version:  master
  checks)|
 Severity:  Normal   |   Resolution:
 Keywords:  decimal, | Triage Stage:  Ready for
  InvalidOperation, migrations   |  checkin
Has patch:  1|  Needs documentation:  1
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-

Comment (by timgraham):

 Thanks for the raising the issue. I figured there would probably be some
 use case where this check would cause problems, however, I don't think
 it's very common to intentionally create models that don't validate. Do
 you have any problem adding this check to `SILENCED_SYSTEM_CHECKS`? We
 could downgrade the check from "error" to "warning" or discuss it further
 on the DevelopersMailingList.

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.53759a1b1ad21cadbc7a1d1f9bfb4a0b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #25417: Add a system check for an invalid default on a model field

2015-10-16 Thread Django
#25417: Add a system check for an invalid default on a model field
-+-
 Reporter:  avorio   |Owner:  charettes
 Type:  New feature  |   Status:  new
Component:  Core (System |  Version:  master
  checks)|
 Severity:  Normal   |   Resolution:
 Keywords:  decimal, | Triage Stage:  Ready for
  InvalidOperation, migrations   |  checkin
Has patch:  1|  Needs documentation:  1
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by gavinwahl):

 * status:  closed => new
 * needs_better_patch:  0 => 1
 * resolution:  fixed =>
 * needs_docs:  0 => 1


Comment:

 This change is not backwards compatible and isn't a valid fix for the
 original issue. Validation in Django only happens through forms, and is
 bypassed when manipulating a model directly. The precedent in Django is to
 allow creation of models that don't actually validate.

 I use fields with `blank=False, default=''` to create a model with empty
 content that's only validated when a user edits it through a form.

 I don't understand how this is a Django bug at all. The opener of the bug
 is doing something wrong with Decimals, and got a decimal.InvalidOperation
 error. That seems like what should happen.

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.e1ca4f82023efc042a0161149f31b5c9%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #25417: Add a system check for an invalid default on a model field

2015-09-18 Thread Django
#25417: Add a system check for an invalid default on a model field
-+-
 Reporter:  avorio   |Owner:  charettes
 Type:  New feature  |   Status:  closed
Component:  Core (System |  Version:  master
  checks)|
 Severity:  Normal   |   Resolution:  fixed
 Keywords:  decimal, | Triage Stage:  Ready for
  InvalidOperation, migrations   |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Simon Charette ):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"71ebcb85b931f43865df5b322b2cf06d3da23f69" 71ebcb8]:
 {{{
 #!CommitTicketReference repository=""
 revision="71ebcb85b931f43865df5b322b2cf06d3da23f69"
 Fixed #25417 -- Added a field check for invalid default values.
 }}}

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.3951124bc505778cf827560dade27e48%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #25417: Add a system check for an invalid default on a model field (was: No warning raised when an invalid default is specified for a field)

2015-09-18 Thread Django
#25417: Add a system check for an invalid default on a model field
-+-
 Reporter:  avorio   |Owner:  charettes
 Type:  New feature  |   Status:  assigned
Component:  Core (System |  Version:  master
  checks)|
 Severity:  Normal   |   Resolution:
 Keywords:  decimal, | Triage Stage:  Ready for
  InvalidOperation, migrations   |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by timgraham):

 * stage:  Accepted => Ready for checkin


--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.05d44d6a180936917ac4688271ff9db9%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.