Re: [Django] #34261: Use {% url model_object %} to work with get_absolute_url

2023-01-15 Thread Django
#34261: Use {% url model_object %} to work with get_absolute_url
--+--
 Reporter:  Willem Van Onsem  |Owner:  nobody
 Type:  New feature   |   Status:  closed
Component:  Template system   |  Version:  4.1
 Severity:  Normal|   Resolution:  wontfix
 Keywords:  url   | Triage Stage:  Unreviewed
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+--

Comment (by Willem Van Onsem):

 Well the confusion started for me... when `redirect` accepts a model
 object, and `{% url ... %}` does not... :P

-- 
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/01070185b9640d22-4c8200aa-0ac3-462c-aea6-28f86a5708ff-00%40eu-central-1.amazonses.com.


Re: [Django] #34261: Use {% url model_object %} to work with get_absolute_url

2023-01-15 Thread Django
#34261: Use {% url model_object %} to work with get_absolute_url
--+--
 Reporter:  Willem Van Onsem  |Owner:  nobody
 Type:  New feature   |   Status:  closed
Component:  Template system   |  Version:  4.1
 Severity:  Normal|   Resolution:  wontfix
 Keywords:  url   | Triage Stage:  Unreviewed
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+--
Changes (by Mariusz Felisiak):

 * status:  new => closed
 * type:  Uncategorized => New feature
 * resolution:   => wontfix


Comment:

 Thanks for this ticket, however, IMO this syntax would be really confusing
 for users as it mixes URL resolvers and model methods. It would also
 unnecessarily complicate an existing Django code.

 Please first start a discussion on the DevelopersMailingList, where you'll
 reach a wider audience and see what other think, and
 [https://docs.djangoproject.com/en/stable/internals/contributing/bugs-and-
 features/#requesting-features follow the guidelines with regards to
 requesting features].

-- 
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/01070185b8fe40a4-c1bb5657-ae7c-49a4-9742-417bfcbd9fe8-00%40eu-central-1.amazonses.com.


Re: [Django] #34260: models.FloatField documentation doesn't mention that +inf, -inf, and NaN are invalid. (was: Field reference documentation doesn't mention that +inf, -inf, and NaN are invalid)

2023-01-15 Thread Django
#34260: models.FloatField documentation doesn't mention that +inf, -inf, and NaN
are invalid.
-+-
 Reporter:  Matt Cooper  |Owner:  nobody
 Type:   |   Status:  closed
  Cleanup/optimization   |
Component:  Documentation|  Version:  4.1
 Severity:  Normal   |   Resolution:  invalid
 Keywords:  floatfield   | Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

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


Comment:

 Storing `inf`, `-inf`, and `nan` in `FloatField` works for me, I don't see
 any protection against them in `models.FloatField`:

 {{{#!diff
 diff --git a/tests/model_fields/test_floatfield.py
 b/tests/model_fields/test_floatfield.py
 index 264b5677e9..e3b3fde380 100644
 --- a/tests/model_fields/test_floatfield.py
 +++ b/tests/model_fields/test_floatfield.py
 @@ -1,3 +1,5 @@
 +import math
 +
  from django.db import transaction
  from django.test import TestCase

 @@ -31,6 +33,16 @@ class TestFloatField(TestCase):
  with self.assertRaisesMessage(TypeError, msg):
  obj.save()

 +def test_save_inf(self):
 +for value in [float("inf"), math.inf, "inf"]:
 +FloatModel.objects.create(size=value)
 +for value in [float("-inf"), -math.inf, "-inf"]:
 + FloatModel.objects.create(size=value)
 +
 +def test_save_nan(self):
 +for value in [float("nan"), math.nan, "nan"]:
 +FloatModel.objects.create(size=value)
 +
  def test_invalid_value(self):
  tests = [
  (TypeError, ()),
 }}}

-- 
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/01070185b8ee1778-10649ebc-f88a-44f8-b838-0c09703b001b-00%40eu-central-1.amazonses.com.


Re: [Django] #34255: Annotation/group by with an expression on psycopg3

2023-01-15 Thread Django
#34255: Annotation/group by with an expression on psycopg3
-+-
 Reporter:  Guillaume Andreu |Owner:  nobody
  Sabater|
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  dev
  (models, ORM)  |
 Severity:  Release blocker  |   Resolution:
 Keywords:  orm postgres | Triage Stage:  Accepted
  psycopg3 annotation groupby|
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Florian Apolloner):

 If my tests didn't fail me, this allows us to switch to client-side
 binding cursors again while enabling the server-side binding via
 `OPTIONS`:
 {{{#!diff
 diff --git a/django/db/backends/postgresql/base.py
 b/django/db/backends/postgresql/base.py
 index 17a3c7a377..ccf483cebf 100644
 --- a/django/db/backends/postgresql/base.py
 +++ b/django/db/backends/postgresql/base.py
 @@ -222,6 +222,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
  conn_params = {**settings_dict["OPTIONS"]}

  conn_params.pop("assume_role", None)
 +conn_params.pop("server_side_binding", None)
  conn_params.pop("isolation_level", None)
  if settings_dict["USER"]:
  conn_params["user"] = settings_dict["USER"]
 @@ -268,14 +269,18 @@ class DatabaseWrapper(BaseDatabaseWrapper):
  connection = self.Database.connect(**conn_params)
  if set_isolation_level:
  connection.isolation_level = self.isolation_level
 -if not is_psycopg3:
 +if is_psycopg3:
 +connection.cursor_factory = (
 +ServerBindingCursor if options.get("server_side_binding")
 else Cursor
 +)
 +else:
  # Register dummy loads() to avoid a round trip from
 psycopg2's
  # decode to json.dumps() to json.loads(), when using a custom
  # decoder in JSONField.
  psycopg2.extras.register_default_jsonb(
  conn_or_curs=connection, loads=lambda x: x
  )
 -connection.cursor_factory = Cursor
 +connection.cursor_factory = Cursor
  return connection

  def ensure_timezone(self):
 @@ -436,11 +441,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):

  if is_psycopg3:

 -class Cursor(Database.Cursor):
 -"""
 -A subclass of psycopg cursor implementing callproc.
 -"""
 -
 +class CursorMixin:
  def callproc(self, name, args=None):
  if not isinstance(name, sql.Identifier):
  name = sql.Identifier(name)
 @@ -457,6 +458,12 @@ if is_psycopg3:
  self.execute(stmt)
  return args

 +class ServerBindingCursor(CursorMixin, Database.Cursor):
 +pass
 +
 +class Cursor(CursorMixin, Database.ClientCursor):
 +pass
 +
  class CursorDebugWrapper(BaseCursorDebugWrapper):
  def copy(self, statement):
  with self.debug_sql(statement):
 }}}

-- 
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/01070185b747443c-04b6d13b-0159-4f45-a6ec-11d880e70444-00%40eu-central-1.amazonses.com.


Re: [Django] #23718: TEST_MIRROR setting doesn't work as expected (and has no tests)

2023-01-15 Thread Django
#23718: TEST_MIRROR setting doesn't work as expected (and has no tests)
-+---
 Reporter:  Ilya Baryshev|Owner:  Sarah Boyce
 Type:  Bug  |   Status:  assigned
Component:  Documentation|  Version:  1.7
 Severity:  Normal   |   Resolution:
 Keywords:  replica testing  | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+---
Changes (by Sarah Boyce):

 * owner:  Christian Bundy => Sarah Boyce
 * needs_better_patch:  1 => 0


Comment:

 [https://github.com/django/django/pull/16458 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/01070185b6cc9fb8-cb1fd1b7-c16f-47db-948e-2d1ee123a848-00%40eu-central-1.amazonses.com.


Re: [Django] #34259: Management command subparsers don’t retain error formatting

2023-01-15 Thread Django
#34259: Management command subparsers don’t retain error formatting
-+-
 Reporter:  Adam Johnson |Owner:  Adam
 |  Johnson
 Type:  Bug  |   Status:  assigned
Component:  Core (Management |  Version:  dev
  commands)  |
 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 Adam Johnson):

 * owner:  (none) => Adam Johnson
 * 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/01070185b691d0a5-774636b0-c6c3-46c7-8553-d207ddbeba61-00%40eu-central-1.amazonses.com.


Re: [Django] #34259: Management command subparsers don’t retain error formatting

2023-01-15 Thread Django
#34259: Management command subparsers don’t retain error formatting
-+-
 Reporter:  Adam Johnson |Owner:  (none)
 Type:  Bug  |   Status:  new
Component:  Core (Management |  Version:  dev
  commands)  |
 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 Jacob Walls):

 * owner:  nobody => (none)
 * status:  assigned => new
 * stage:  Unreviewed => Accepted


-- 
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/01070185b6170858-8a2d62a4-b34e-481b-b17e-74da58367c30-00%40eu-central-1.amazonses.com.


[Django] #34261: Use {% url model_object %} to work with get_absolute_url

2023-01-15 Thread Django
#34261: Use {% url model_object %} to work with get_absolute_url
+
   Reporter:  Willem Van Onsem  |  Owner:  nobody
   Type:  Uncategorized | Status:  new
  Component:  Template system   |Version:  4.1
   Severity:  Normal|   Keywords:  url
   Triage Stage:  Unreviewed|  Has patch:  0
Needs documentation:  0 |Needs tests:  0
Patch needs improvement:  0 |  Easy pickings:  0
  UI/UX:  0 |
+
 Django has a `{% url ... %}` tag to calculate a reverse url. The advantage
 of this is that it raises an error in case the url can not be found, and
 thus makes templates less buggy.m

 An alternative is to define a `.get_absolute_url()` method on a model
 object, and then use it in the template as `{{
 model_object.get_absolute_url() }}`. If a model object however has no
 `get_absolute_url` method, it will return an empty href, not an error.

 We can combine the two and check if the first parameter has a
 `get_absolute_url` method, if that is the case, we return the result of
 `get_absolute_url` instead.

-- 
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/01070185b573b055-f594bcec-785b-4835-8621-d6538ecbfe6e-00%40eu-central-1.amazonses.com.


Re: [Django] #34260: Field reference documentation doesn't mention that +inf, -inf, and NaN are invalid

2023-01-15 Thread Django
#34260: Field reference documentation doesn't mention that +inf, -inf, and NaN 
are
invalid
-+-
 Reporter:  Matt Cooper  |Owner:  nobody
 Type:   |   Status:  new
  Cleanup/optimization   |
Component:  Documentation|  Version:  4.1
 Severity:  Normal   |   Resolution:
 Keywords:  floatfield   | Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-

Comment (by Matt Cooper):

 https://github.com/django/django/pull/16455 proposes a fix for the dev
 documentation. This change could (should?) also be backported to all
 supported Django versions.

-- 
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/01070185b54209b9-c112cb7b-0b57-4b22-847e-a804726eb0d4-00%40eu-central-1.amazonses.com.


[Django] #34260: Field reference documentation doesn't mention that +inf, -inf, and NaN are invalid

2023-01-15 Thread Django
#34260: Field reference documentation doesn't mention that +inf, -inf, and NaN 
are
invalid
-+-
   Reporter:  Matt   |  Owner:  nobody
  Cooper |
   Type: | Status:  new
  Cleanup/optimization   |
  Component: |Version:  4.1
  Documentation  |
   Severity:  Normal |   Keywords:  floatfield
   Triage Stage: |  Has patch:  0
  Unreviewed |
Needs documentation:  0  |Needs tests:  0
Patch needs improvement:  0  |  Easy pickings:  1
  UI/UX:  0  |
-+-
 The model field reference documentation doesn't mention that, in a
 FloatField, the values must pass `math.isfinite`. This excludes
 `float('inf')` (positive and negative) and `float('nan')`. I saw old
 discussion about why this is the case, but only after being bitten by it
 in a project. I'd like to submit a patch adding this info to the docs.

-- 
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/01070185b53a2693-7ff9574a-a7f6-47ee-859c-63c951b9d6b7-00%40eu-central-1.amazonses.com.


Re: [Django] #30129: Allow creating models with fields values as a Subquery() with F() expressions

2023-01-15 Thread Django
#30129: Allow creating models with fields values as a Subquery() with F()
expressions
-+-
 Reporter:  Charlie McBride  |Owner:  Sarah
 |  Boyce
 Type:  New feature  |   Status:  assigned
Component:  Database layer   |  Version:  2.1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  Subquery, F, Query   | Triage Stage:  Accepted
  Expressions|
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Sarah Boyce):

 Thank you Tim! Updated the commit message to credit 👍

-- 
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/01070185b50885fc-1019df79-da48-4a09-b0ca-55b239a36732-00%40eu-central-1.amazonses.com.


[Django] #34259: Management command subparsers don’t retain error formatting

2023-01-15 Thread Django
#34259: Management command subparsers don’t retain error formatting
-+-
   Reporter:  Adam   |  Owner:  nobody
  Johnson|
   Type:  Bug| Status:  assigned
  Component:  Core   |Version:  dev
  (Management commands)  |
   Severity:  Normal |   Keywords:
   Triage Stage: |  Has patch:  0
  Unreviewed |
Needs documentation:  0  |Needs tests:  0
Patch needs improvement:  0  |  Easy pickings:  0
  UI/UX:  0  |
-+-
 Django management commands use a subclass of `argparse.ArgumentParser`,
 `CommandParser`, that takes some extra arguments to improve error
 formatting. These arguments are not copied into subparsers, created via
 `CommandParser.add_subparsers().add_parser()`. Missing arguments to
 subparsers thus end as stack traces on the CLI, rather than human-facing
 usage messages.

 For example take this command with a subparser:

 {{{
 from django.core.management.base import BaseCommand


 class Command(BaseCommand):
 def add_arguments(self, parser):
 subparsers = parser.add_subparsers(required=True)
 create = subparsers.add_parser("create")
 create.add_argument("name")

 def handle(self, *args, **options):
 pass
 }}}

 Missing the required subparser name argument gives the usage message, as
 for any normal argument:

 {{{
 $ ./manage.py cheeses
 usage: manage.py cheeses [-h] [--version] [-v {0,1,2,3}] [--settings
 SETTINGS] [--pythonpath PYTHONPATH] [--traceback] [--no-color] [--force-
 color] [--skip-checks] {create} ...
 manage.py cheeses: error: the following arguments are required: {create}
 }}}

 But missing the name argument to `create` fails with a stacktrace:

 {{{
 $  ./manage.py cheeses create
 Traceback (most recent call last):
   File "/Users/chainz/tmp/subparserstest/./manage.py", line 21, in
 
 main()
 ...
   File "/Users/chainz/.pyenv/versions/3.11.0/lib/python3.11/argparse.py",
 line 2131, in _parse_known_args
 self.error(_('the following arguments are required: %s') %
   File
 "/Users/chainz/Documents/Projects/django/django/core/management/base.py",
 line 72, in error
 raise CommandError("Error: %s" % message)
 django.core.management.base.CommandError: Error: the following arguments
 are required: name
 }}}

 We can correct this by ensuring that the subparser action returned by
 `add_subparsers()` copies the relevant arguments through to constructed
 subparsers.

 (Originally reported by Mark Gregson on django-developers:
 https://groups.google.com/g/django-developers/c/oWcaxkxQ-KI/m/4NUhLjddBwAJ
 )

-- 
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/01070185b48ff3fe-ea974df0-bcad-4c73-bf27-5351fe1e4326-00%40eu-central-1.amazonses.com.