Re: [Django] #24561: Allow model field choices to accept callables.

2023-09-14 Thread Django
#24561: Allow model field choices to accept callables.
-+-
 Reporter:  Christopher Grebs|Owner:  Natalia
 |  Bidart
 Type:  New feature  |   Status:  closed
Component:  Database layer   |  Version:  dev
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  fixed
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  1
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Natalia Bidart):

 * 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018a9473173b-b2a2055b-5169-4885-998d-3436571c7a08-00%40eu-central-1.amazonses.com.


Re: [Django] #24561: Allow model field choices to accept callables.

2023-09-14 Thread Django
#24561: Allow model field choices to accept callables.
-+-
 Reporter:  Christopher Grebs|Owner:  Natalia
 |  Bidart
 Type:  New feature  |   Status:  closed
Component:  Database layer   |  Version:  dev
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  fixed
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  1
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Natalia <124304+nessita@…>):

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


Comment:

 In [changeset:"691f70c47755c7f55fa75ce607d028f81468b745" 691f70c]:
 {{{
 #!CommitTicketReference repository=""
 revision="691f70c47755c7f55fa75ce607d028f81468b745"
 Fixed #24561 -- Added support for callables on model fields' choices.
 }}}

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018a9407ed76-aacde051-338a-493e-82f5-95c040c6a22e-00%40eu-central-1.amazonses.com.


Re: [Django] #24561: Allow model field choices to accept callables.

2023-09-06 Thread Django
#24561: Allow model field choices to accept callables.
-+-
 Reporter:  Christopher Grebs|Owner:  Natalia
 |  Bidart
 Type:  New feature  |   Status:  assigned
Component:  Database layer   |  Version:  dev
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  1
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Natalia Bidart):

 [https://forum.djangoproject.com/t/callables-for-model-fields-
 choices/23654 Forum Post]

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018a6a81456d-3bd0c8d0-6e09-458f-8f4b-d97da8c19b48-00%40eu-central-1.amazonses.com.


Re: [Django] #24561: Allow model field choices to accept callables.

2023-09-04 Thread Django
#24561: Allow model field choices to accept callables.
-+-
 Reporter:  Christopher Grebs|Owner:  Natalia
 |  Bidart
 Type:  New feature  |   Status:  assigned
Component:  Database layer   |  Version:  dev
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  1
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Ülgen Sarıkavak):

 * cc: Ülgen Sarıkavak (added)


-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018a610f2023-5086737c-6cd2-4e59-8472-84d6447b4415-00%40eu-central-1.amazonses.com.


Re: [Django] #24561: Allow model field choices to accept callables.

2023-09-04 Thread Django
#24561: Allow model field choices to accept callables.
-+-
 Reporter:  Christopher Grebs|Owner:  Natalia
 |  Bidart
 Type:  New feature  |   Status:  assigned
Component:  Database layer   |  Version:  dev
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  1
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Natalia Bidart):

 * needs_better_patch:  0 => 1
 * needs_docs:  0 => 1


Comment:

 Setting as patch needs improvement because I'd like to cover a few use
 cases with the community first.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018a60a8e5a3-fd53bddb-492f-4b22-82c4-167394af8cd7-00%40eu-central-1.amazonses.com.


Re: [Django] #24561: Allow model field choices to accept callables.

2023-08-31 Thread Django
#24561: Allow model field choices to accept callables.
-+-
 Reporter:  Christopher Grebs|Owner:  Natalia
 |  Bidart
 Type:  New feature  |   Status:  assigned
Component:  Database layer   |  Version:  dev
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Natalia Bidart):

 * has_patch:  0 => 1


Comment:

 [https://github.com/django/django/pull/17214 PR]

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018a4e5f3ed9-efadfc42-55f7-485f-9a64-f31a27340b6e-00%40eu-central-1.amazonses.com.


Re: [Django] #24561: Allow model field choices to accept callables.

2023-08-30 Thread Django
#24561: Allow model field choices to accept callables.
-+-
 Reporter:  Christopher Grebs|Owner:  Natalia
 |  Bidart
 Type:  New feature  |   Status:  assigned
Component:  Database layer   |  Version:  dev
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Natalia Bidart):

 * owner:  nobody => Natalia Bidart
 * status:  new => assigned


-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018a4955042b-b1c3f2b3-f64b-4d2f-b69e-4e96757c3c5c-00%40eu-central-1.amazonses.com.


Re: [Django] #24561: Allow model field choices to accept callables.

2023-08-26 Thread Django
#24561: Allow model field choices to accept callables.
-+-
 Reporter:  Christopher Grebs|Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Database layer   |  Version:  dev
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Sergey Fedoseev):

 * cc: Sergey Fedoseev (removed)


-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018a3085812b-79407a63-9a85-4f80-8dd6-3902d67d670c-00%40eu-central-1.amazonses.com.


Re: [Django] #24561: Allow model field choices to accept callables.

2023-08-24 Thread Django
#24561: Allow model field choices to accept callables.
-+-
 Reporter:  Christopher Grebs|Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Database layer   |  Version:  dev
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Natalia Bidart):

 While reviewing/working on #31262, we noticed that the choices refactoring
 that is being proposed in [https://github.com/django/django/pull/16943 PR
 #16943] will help considerably to this ticket. Besides what is discussed
 in that PR, the following diff should allow model field's callable
 `choices` to be serialized as functions (similar to callable `default` or
 form ChoiceField's `choices`).

 {{{
 #!diff
 diff --git a/django/db/migrations/serializer.py
 b/django/db/migrations/serializer.py
 index 06657ebaab..2c57a21b7c 100644
 --- a/django/db/migrations/serializer.py
 +++ b/django/db/migrations/serializer.py
 @@ -15,6 +15,7 @@ from django.conf import SettingsReference
  from django.db import models
  from django.db.migrations.operations.base import Operation
  from django.db.migrations.utils import COMPILED_REGEX_TYPE, RegexObject
 +from django.utils.choices import CallableChoiceIterator
  from django.utils.functional import LazyObject, Promise
  from django.utils.version import PY311, get_docs_version

 @@ -329,6 +330,12 @@ class UUIDSerializer(BaseSerializer):
  return "uuid.%s" % repr(self.value), {"import uuid"}


 +class CallableChoiceIteratorSerializer(BaseSerializer):
 +
 +def serialize(self):
 +return
 FunctionTypeSerializer(self.value.choices_func).serialize()
 +
 +
  class Serializer:
  _registry = {
  # Some of these are order-dependent.
 @@ -351,6 +358,7 @@ class Serializer:
  types.BuiltinFunctionType,
  types.MethodType,
  ): FunctionTypeSerializer,
 +CallableChoiceIterator: CallableChoiceIteratorSerializer,
  collections.abc.Iterable: IterableSerializer,
  (COMPILED_REGEX_TYPE, RegexObject): RegexSerializer,
  uuid.UUID: UUIDSerializer,
 diff --git a/django/db/models/fields/__init__.py
 b/django/db/models/fields/__init__.py
 index 7e56bddffe..6600031cf6 100644
 --- a/django/db/models/fields/__init__.py
 +++ b/django/db/models/fields/__init__.py
 @@ -315,9 +315,7 @@ class Field(RegisterLookupMixin):
  if not self.choices:
  return []

 -if not is_iterable(self.choices) or isinstance(
 -self.choices, (str, CallableChoiceIterator)
 -):
 +if not is_iterable(self.choices) or isinstance(self.choices,
 str):
  return [
  checks.Error(
  "'choices' must be a mapping (e.g. a dictionary) or
 an iterable "
 }}}

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018a2916eb66-e462b05c-fc18-457c-a922-a7db08b50b3f-00%40eu-central-1.amazonses.com.


Re: [Django] #24561: Allow model field choices to accept callables.

2017-11-10 Thread Django
#24561: Allow model field choices to accept callables.
-+-
 Reporter:  Christopher Grebs|Owner:  Sergey
 |  Fedoseev
 Type:  New feature  |   Status:  assigned
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Sergey Fedoseev):

 * status:  new => assigned
 * owner:  nobody => Sergey Fedoseev


-- 
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/066.a84b3ab7c25e68a2933fdbf2342db5b2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24561: Allow model field choices to accept callables.

2017-10-25 Thread Django
#24561: Allow model field choices to accept callables.
-+-
 Reporter:  Christopher Grebs|Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Sergey Fedoseev):

 * cc: Sergey Fedoseev (added)


-- 
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/066.aacfe769b2a391cf939580dd69d199ab%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24561: Allow model field choices to accept callables.

2017-04-20 Thread Django
#24561: Allow model field choices to accept callables.
-+-
 Reporter:  Christopher Grebs|Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by felixxm):

 * needs_better_patch:  1 => 0
 * has_patch:  1 => 0


Comment:

 See also discussion in #28033.

--
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/066.8403989364aecdbefcd3ac9de5f3938a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24561: Allow model field choices to accept callables.

2015-04-02 Thread Django
#24561: Allow model field choices to accept callables.
-+-
 Reporter:  EnTeQuAk |Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-

Comment (by EnTeQuAk):

 Oh, then I misread the feature. I'll try to update the patch to port this
 to the model field `choices` as well.

--
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/066.6c2b2dde26fb6e1d97467ee4a249e4f5%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24561: Allow model field choices to accept callables. (was: Allow 'choices'-check to work for callables.)

2015-04-02 Thread Django
#24561: Allow model field choices to accept callables.
-+-
 Reporter:  EnTeQuAk |Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by timgraham):

 * needs_better_patch:   => 1
 * component:  Core (System checks) => Database layer (models, ORM)
 * needs_tests:   => 0
 * version:  1.8 => master
 * needs_docs:   => 0
 * type:  Bug => New feature
 * stage:  Unreviewed => Accepted


Comment:

 It was added for `django.forms.ChoiceField`, but not model field
 `choices`. It might be a reasonable feature request, but it needs to be
 implemented. It might cause some difficulty in migrations, but I will
 accept the ticket if someone wants to investigate the possibility.

--
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/066.282c9d507b472e04a1d06aa1b17f2dc1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.