Re: [Django] #34380: Make URLField assume "https".

2023-04-27 Thread Django
#34380: Make URLField assume "https".
-+-
 Reporter:  Coen van der Kamp|Owner:  Coen van
 Type:   |  der Kamp
  Cleanup/optimization   |   Status:  closed
Component:  Forms|  Version:  4.1
 Severity:  Normal   |   Resolution:  fixed
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak ):

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


Comment:

 In [changeset:"7bbbadc69383f0a2b99253e153b974f8783e876d" 7bbbadc6]:
 {{{
 #!CommitTicketReference repository=""
 revision="7bbbadc69383f0a2b99253e153b974f8783e876d"
 Fixed #34380 -- Allowed specifying a default URL scheme in forms.URLField.

 This also deprecates "http" as the default scheme.
 }}}

-- 
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/01070187c65bb2eb-f1895618-9680-45c8-ae05-b6d33b923136-00%40eu-central-1.amazonses.com.


Re: [Django] #34520: ModelAdmin.fields: wrapping in tuples does not have any effect (each field on separate line)

2023-04-27 Thread Django
#34520: ModelAdmin.fields: wrapping in tuples does not have any effect (each 
field
on separate line)
-+-
 Reporter:  Stefan Vollmar   |Owner:  nobody
 Type:  Uncategorized|   Status:  closed
Component:  contrib.admin|  Version:  4.2
 Severity:  Release blocker  |   Resolution:  needsinfo
 Keywords:  ModelAdmin fields| Triage Stage:
  wrapping tuples multiple-fields-   |  Unreviewed
  per-line   |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  1
-+-

Comment (by Natalia Bidart):

 Could you try with the Django's ModelAdmin instead? If you can't reproduce
 in that case, then it seems this is something to report to `django-
 reversion`.

-- 
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/01070187c47afec8-8f3dc2be-4eed-471f-9a1c-a2039ea84b71-00%40eu-central-1.amazonses.com.


Re: [Django] #33213: Document coverage setup for parallel tests

2023-04-27 Thread Django
#33213: Document coverage setup for parallel tests
-+-
 Reporter:  Mr. Glass|Owner:  Paolo
 |  Melchiorre
 Type:  New feature  |   Status:  closed
Component:  Documentation|  Version:
 Severity:  Normal   |   Resolution:  fixed
 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 GitHub ):

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


Comment:

 In [changeset:"070cbac0dbf6a09b55aad322137ab168b75bf56b" 070cbac]:
 {{{
 #!CommitTicketReference repository=""
 revision="070cbac0dbf6a09b55aad322137ab168b75bf56b"
 Restored multiprocessing concurrency on coverage.py settings

 * Revert "Reverted "Fixed #33213 -- Doc'd testing code coverage in
 parallel and used it.""

 This reverts commit 78da5ca0c1f2ab3201f8f6cd629e80d805ea023d.

 * Restored coverage multiprocess concurrency with threads

 Investigating https://github.com/nedbat/coveragepy/issues/1585 revealed
 that thread tracing gets disabled when passing
 `concurrency = multiprocessing`. Adding `thread` restores it, and
 ensures that the `auser()` is reported as covered since the test suite
 uses `AsyncToSync` to execute this middleware (which spawns threads).
 }}}

-- 
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/01070187c4502c47-01d177fa-f822-42a7-8f9b-fc014f92ffce-00%40eu-central-1.amazonses.com.


Re: [Django] #34523: update_or_create not work in parallel insertion

2023-04-27 Thread Django
#34523: update_or_create not work in parallel insertion
-+-
 Reporter:  gatello-s|Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  4.2
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  needsinfo
 Keywords:  update_or_create | Triage Stage:
  TransactionManagementError |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Mariusz Felisiak):

 > Backends that don't support transactions is not a particularly well
 tested area of the code base. Do we even run the full test suite against
 MyISAM?

 I'm doing this from time to time (e.g.
 73766c118781a7f7052bf0a5fbee38b944964e31,
 8e89dfe1c24540d33b577377af633694ff57f505, or
 331a460f8f2e4f447b68fba491464b68c9b21fd1.)

-- 
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/01070187c3df9350-ae8f10be-508c-4117-a496-656113aac4a0-00%40eu-central-1.amazonses.com.


Re: [Django] #33662: Choose which items are displayed per language in Sitemap

2023-04-27 Thread Django
#33662: Choose which items are displayed per language in Sitemap
-+-
 Reporter:  Roxane   |Owner:  Roxane
 Type:  New feature  |   Status:  closed
Component:  contrib.sitemaps |  Version:  4.0
 Severity:  Normal   |   Resolution:  fixed
 Keywords:  sitemap  | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Mariusz Felisiak ):

 In [changeset:"88f23b6b8158d3830589dce8787677cdb7d33404" 88f23b6b]:
 {{{
 #!CommitTicketReference repository=""
 revision="88f23b6b8158d3830589dce8787677cdb7d33404"
 [4.2.x] Refs #33662 -- Corrected Sitemap.get_languages_for_item()
 signature in docs.

 Backport of 5c456a879300e5f51010d3f6aa7449302413efed from main
 }}}

-- 
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/01070187c3da90ba-66155693-5cbd-4a6d-a51d-110ee56aa3a3-00%40eu-central-1.amazonses.com.


Re: [Django] #33662: Choose which items are displayed per language in Sitemap

2023-04-27 Thread Django
#33662: Choose which items are displayed per language in Sitemap
-+-
 Reporter:  Roxane   |Owner:  Roxane
 Type:  New feature  |   Status:  closed
Component:  contrib.sitemaps |  Version:  4.0
 Severity:  Normal   |   Resolution:  fixed
 Keywords:  sitemap  | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by GitHub ):

 In [changeset:"5c456a879300e5f51010d3f6aa7449302413efed" 5c456a8]:
 {{{
 #!CommitTicketReference repository=""
 revision="5c456a879300e5f51010d3f6aa7449302413efed"
 Refs #33662 -- Corrected Sitemap.get_languages_for_item() signature in
 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/01070187c3d9fab2-4dfa8ef3-8ad9-4b55-9bbd-d2fa6275014f-00%40eu-central-1.amazonses.com.


Re: [Django] #34523: update_or_create not work in parallel insertion

2023-04-27 Thread Django
#34523: update_or_create not work in parallel insertion
-+-
 Reporter:  gatello-s|Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  4.2
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  needsinfo
 Keywords:  update_or_create | Triage Stage:
  TransactionManagementError |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by David Sanders):

 Ok so I think I get what OP is reporting here, but when I run the above
 test on latest main, it works fine.

  - The above test creates an InnoDB table; this causes the test with the
 duplicate `create()` calls in the manager to abort the transaction because
 we can't have 2 rows with pk=1
  - After editing the test to create a MyISAM the test starts passing - I
 see no issue.

 I'd ask if OP can please make sure the test is run against latest main.

-- 
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/01070187c331e9bf-641b6d16-a086-4f9b-89cf-cb2a2e5f5409-00%40eu-central-1.amazonses.com.


Re: [Django] #34523: update_or_create not work in parallel insertion

2023-04-27 Thread Django
#34523: update_or_create not work in parallel insertion
-+-
 Reporter:  gatello-s|Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  4.2
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  needsinfo
 Keywords:  update_or_create | Triage Stage:
  TransactionManagementError |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Simon Charette):

 Backends that don't support transactions is not a particularly well tested
 area of the code base. Do we even run the full test suite against MyISAM?

 I'm curious as to whether you run into the same issue by making your
 `TransactionManagementErrorTest` testcase extend `TransationTestCase`
 instead of `TestCase`. I would expect `transaction.atomic` to be a noop
 when the backend doesn't support transactions so I wouldn't be surprised
 if there was an issue with nested `atomic` blocks on such backends as they
 also don't support savepoints by definition (Remember that `TestCase`
 wraps each tests in an outer `atomic` block).

-- 
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/01070187c330f69f-158c0ed5-fd56-4125-bc31-b8ddc2b98d9e-00%40eu-central-1.amazonses.com.


Re: [Django] #34523: update_or_create not work in parallel insertion

2023-04-27 Thread Django
#34523: update_or_create not work in parallel insertion
-+-
 Reporter:  gatello-s|Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  4.2
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  needsinfo
 Keywords:  update_or_create | Triage Stage:
  TransactionManagementError |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by gatello-s):

 code from db/models/query.py

 {{{
 return self.create(**params), True
 }}}
 **  # test generate IntegrityError, this ok**

 {{{
 return self.get(**kwargs), False
 }}}
 **  # this must work fine, but raise
 django.db.transaction.TransactionManagementError**

 {{{
 def get_or_create(self, defaults=None, **kwargs):
 """
 Look up an object with the given kwargs, creating one if
 necessary.
 Return a tuple of (object, created), where created is a boolean
 specifying whether an object was created.
 """
 # The get() needs to be targeted at the write database in order
 # to avoid potential transaction consistency problems.
 self._for_write = True
 try:
 return self.get(**kwargs), False
 except self.model.DoesNotExist:
 params = self._extract_model_params(defaults, **kwargs)
 # Try to create an object using passed params.
 try:
 with transaction.atomic(using=self.db):
 params = dict(resolve_callables(params))
 return self.create(**params), True  # test generate
 IntegrityError, this ok
 except IntegrityError:
 try:
 return self.get(**kwargs), False  # this must work
 fine, but raise django.db.transaction.TransactionManagementError
 except self.model.DoesNotExist:
 pass
 raise
 }}}

 

 {{{
 ERROR: test_update_or_create (polls.tests.TransactionManagementErrorTest)
 --
 Traceback (most recent call last):
   File
 "/home/alex/workspace/test_TransactionManagementError/.venv/lib/python3.9
 /site-packages/django/db/models/query.py", line 916, in get_or_create
 return self.get(**kwargs), False
   File
 "/home/alex/workspace/test_TransactionManagementError/.venv/lib/python3.9
 /site-packages/django/db/models/query.py", line 637, in get
 raise self.model.DoesNotExist(
 polls.tests.TransactionManagementErrorTest.TestModel.DoesNotExist:
 TestModel matching query does not exist.

 During handling of the above exception, another exception occurred:

 Traceback (most recent call last):
   File
 "/home/alex/workspace/test_TransactionManagementError/.venv/lib/python3.9
 /site-packages/django/db/backends/utils.py", line 89, in _execute
 return self.cursor.execute(sql, params)
   File
 "/home/alex/workspace/test_TransactionManagementError/.venv/lib/python3.9
 /site-packages/django/db/backends/mysql/base.py", line 75, in execute
 return self.cursor.execute(query, args)
   File
 "/home/alex/workspace/test_TransactionManagementError/.venv/lib/python3.9
 /site-packages/MySQLdb/cursors.py", line 206, in execute
 res = self._query(query)
   File
 "/home/alex/workspace/test_TransactionManagementError/.venv/lib/python3.9
 /site-packages/MySQLdb/cursors.py", line 320, in _query
 self._do_get_result(db)
   File
 "/home/alex/workspace/test_TransactionManagementError/.venv/lib/python3.9
 /site-packages/MySQLdb/cursors.py", line 145, in _do_get_result
 self._result = result = self._get_result()
   File
 "/home/alex/workspace/test_TransactionManagementError/.venv/lib/python3.9
 /site-packages/MySQLdb/cursors.py", line 352, in _get_result
 return self._get_db().store_result()
 MySQLdb.IntegrityError: (1062, "Duplicate entry '1' for key 'PRIMARY'")

 The above exception was the direct cause of the following exception:

 Traceback (most recent call last):
   File
 "/home/alex/workspace/test_TransactionManagementError/.venv/lib/python3.9
 /site-packages/django/db/models/query.py", line 923, in get_or_create
 return self.create(**params), True
   File
 "/home/alex/workspace/test_TransactionManagementError/mysite/polls/tests.py",
 line 19, in create
 return super().create(**kwargs)
   File
 "/home/alex/workspace/test_TransactionManagementError/.venv/lib/python3.9
 /site-packages/django/db/models/query.py", line 658, in create
 obj.save(force_insert=True, using=self.db)
   File
 

Re: [Django] #34523: update_or_create not work in parallel insertion

2023-04-27 Thread Django
#34523: update_or_create not work in parallel insertion
-+-
 Reporter:  gatello-s|Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  4.2
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  needsinfo
 Keywords:  update_or_create | Triage Stage:
  TransactionManagementError |  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
 * resolution:   => needsinfo


Comment:

 I'd be surprise at any change in the behavior here. Also, MyISAM storage
 engine doesn't support transactions, etc. I don't think you've explained
 the issue in enough detail to confirm a bug in Django. Please reopen the
 ticket if you can debug your issue and provide details about why and where
 Django is at fault.

-- 
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/01070187c2ecc2c6-e9369b8d-7515-4781-a30d-cdfb345be0d1-00%40eu-central-1.amazonses.com.


Re: [Django] #34523: update_or_create not work in parallel insertion

2023-04-27 Thread Django
#34523: update_or_create not work in parallel insertion
-+-
 Reporter:  gatello-s|Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  4.2
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  update_or_create | Triage Stage:
  TransactionManagementError |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Natalia Bidart):

 Besides knowing what exception the reporter is getting, I would like to
 understand what is the desired outcome, considering that the test is
 setting the same id for both insertions. I would expect an IntegrityError
 as shown by David.

-- 
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/01070187c2d94133-f573deef-307f-4725-9405-d699468ac2b6-00%40eu-central-1.amazonses.com.


Re: [Django] #34523: update_or_create not work in parallel insertion

2023-04-27 Thread Django
#34523: update_or_create not work in parallel insertion
-+-
 Reporter:  gatello-s|Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  4.2
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  update_or_create | Triage Stage:
  TransactionManagementError |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by David Sanders):

 Ah sorry I had an environment issue , here's the exception I'm getting for
 3.2.16:

 {{{
 ==
 ERROR: test_update_or_create
 (ticket_34523.tests.TransactionManagementErrorTest.test_update_or_create)
 --
 Traceback (most recent call last):
   File "/Users/dsanders/projects/django-sample-
 3_2/.direnv/python-3.11.2/lib/python3.11/site-
 packages/django/db/models/query.py", line 581, in get_or_create
 return self.get(**kwargs), False
^^
   File "/Users/dsanders/projects/django-sample-
 3_2/.direnv/python-3.11.2/lib/python3.11/site-
 packages/django/db/models/query.py", line 435, in get
 raise self.model.DoesNotExist(
 ticket_34523.tests.TransactionManagementErrorTest.TestModel.DoesNotExist:
 TestModel matching query does not exist.

 During handling of the above exception, another exception occurred:

 Traceback (most recent call last):
   File "/Users/dsanders/projects/django-sample-
 3_2/.direnv/python-3.11.2/lib/python3.11/site-
 packages/django/db/backends/utils.py", line 84, in _execute
 return self.cursor.execute(sql, params)

   File "/Users/dsanders/projects/django-sample-
 3_2/.direnv/python-3.11.2/lib/python3.11/site-
 packages/django/db/backends/sqlite3/base.py", line 423, in execute
 return Database.Cursor.execute(self, query, params)

 sqlite3.IntegrityError: UNIQUE constraint failed:
 test_model_update_or_create.id

 The above exception was the direct cause of the following exception:

 Traceback (most recent call last):
   File "/Users/dsanders/projects/django-sample-3_2/ticket_34523/tests.py",
 line 42, in test_update_or_create
 self.TestModel.objects.update_or_create(id=1, defaults={"field": 2})
   File "/Users/dsanders/projects/django-sample-
 3_2/.direnv/python-3.11.2/lib/python3.11/site-
 packages/django/db/models/manager.py", line 85, in manager_method
 return getattr(self.get_queryset(), name)(*args, **kwargs)
^^^
   File "/Users/dsanders/projects/django-sample-
 3_2/.direnv/python-3.11.2/lib/python3.11/site-
 packages/django/db/models/query.py", line 608, in update_or_create
 obj, created = self.select_for_update().get_or_create(defaults,
 **kwargs)
 ^^
   File "/Users/dsanders/projects/django-sample-
 3_2/.direnv/python-3.11.2/lib/python3.11/site-
 packages/django/db/models/query.py", line 588, in get_or_create
 return self.create(**params), True
^
   File "/Users/dsanders/projects/django-sample-3_2/ticket_34523/tests.py",
 line 16, in create
 return super().create(**kwargs)

   File "/Users/dsanders/projects/django-sample-
 3_2/.direnv/python-3.11.2/lib/python3.11/site-
 packages/django/db/models/query.py", line 453, in create
 obj.save(force_insert=True, using=self.db)
   File "/Users/dsanders/projects/django-sample-
 3_2/.direnv/python-3.11.2/lib/python3.11/site-
 packages/django/db/models/base.py", line 739, in save
 self.save_base(using=using, force_insert=force_insert,
   File "/Users/dsanders/projects/django-sample-
 3_2/.direnv/python-3.11.2/lib/python3.11/site-
 packages/django/db/models/base.py", line 776, in save_base
 updated = self._save_table(
   ^
   File "/Users/dsanders/projects/django-sample-
 3_2/.direnv/python-3.11.2/lib/python3.11/site-
 packages/django/db/models/base.py", line 881, in _save_table
 results = self._do_insert(cls._base_manager, using, fields,
 returning_fields, raw)
 
   File "/Users/dsanders/projects/django-sample-
 3_2/.direnv/python-3.11.2/lib/python3.11/site-
 packages/django/db/models/base.py", line 919, in _do_insert
 return manager._insert(

   File 

Re: [Django] #34523: update_or_create not work in parallel insertion

2023-04-27 Thread Django
#34523: update_or_create not work in parallel insertion
-+-
 Reporter:  gatello-s|Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  4.2
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  update_or_create | Triage Stage:
  TransactionManagementError |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by David Sanders):

 I ran the test above (I had to add managed=False to the model) on 3.2.16
 and I get the same error as it does on main.

 Here's the failure with stack trace:

 {{{
 ==
 ERROR: test_update_or_create
 (ticket_34523.tests.TransactionManagementErrorTest)
 --
 Traceback (most recent call last):
   File "/Users/dsanders/projects/django-sample/django/db/models/query.py",
 line 581, in get_or_create
 return self.get(**kwargs), False
   File "/Users/dsanders/projects/django-sample/django/db/models/query.py",
 line 435, in get
 raise self.model.DoesNotExist(
 ticket_34523.tests.TransactionManagementErrorTest.TestModel.DoesNotExist:
 TestModel matching query does not exist.

 During handling of the above exception, another exception occurred:

 Traceback (most recent call last):
   File "/Users/dsanders/projects/django-
 sample/django/db/backends/utils.py", line 84, in _execute
 return self.cursor.execute(sql, params)
   File "/Users/dsanders/projects/django-
 sample/django/db/backends/mysql/base.py", line 73, in execute
 return self.cursor.execute(query, args)
   File "/Users/dsanders/projects/django-
 sample/.direnv/python-3.10.8/lib/python3.10/site-
 packages/MySQLdb/cursors.py", line 206, in execute
 res = self._query(query)
   File "/Users/dsanders/projects/django-
 sample/.direnv/python-3.10.8/lib/python3.10/site-
 packages/MySQLdb/cursors.py", line 319, in _query
 db.query(q)
   File "/Users/dsanders/projects/django-
 sample/.direnv/python-3.10.8/lib/python3.10/site-
 packages/MySQLdb/connections.py", line 255, in query
 _mysql.connection.query(self, query)
 MySQLdb.IntegrityError: (1062, "Duplicate entry '1' for key
 'test_model_update_or_create.PRIMARY'")

 The above exception was the direct cause of the following exception:

 Traceback (most recent call last):
   File "/Users/dsanders/projects/django-sample/ticket_34523/tests.py",
 line 44, in test_update_or_create
 self.TestModel.objects.update_or_create(id=1, defaults={"field": 2})
   File "/Users/dsanders/projects/django-
 sample/django/db/models/manager.py", line 85, in manager_method
 return getattr(self.get_queryset(), name)(*args, **kwargs)
   File "/Users/dsanders/projects/django-sample/django/db/models/query.py",
 line 608, in update_or_create
 obj, created = self.select_for_update().get_or_create(defaults,
 **kwargs)
   File "/Users/dsanders/projects/django-sample/django/db/models/query.py",
 line 588, in get_or_create
 return self.create(**params), True
   File "/Users/dsanders/projects/django-sample/ticket_34523/tests.py",
 line 16, in create
 return super().create(**kwargs)
   File "/Users/dsanders/projects/django-sample/django/db/models/query.py",
 line 453, in create
 obj.save(force_insert=True, using=self.db)
   File "/Users/dsanders/projects/django-sample/django/db/models/base.py",
 line 739, in save
 self.save_base(using=using, force_insert=force_insert,
   File "/Users/dsanders/projects/django-sample/django/db/models/base.py",
 line 776, in save_base
 updated = self._save_table(
   File "/Users/dsanders/projects/django-sample/django/db/models/base.py",
 line 881, in _save_table
 results = self._do_insert(cls._base_manager, using, fields,
 returning_fields, raw)
   File "/Users/dsanders/projects/django-sample/django/db/models/base.py",
 line 919, in _do_insert
 return manager._insert(
   File "/Users/dsanders/projects/django-
 sample/django/db/models/manager.py", line 85, in manager_method
 return getattr(self.get_queryset(), name)(*args, **kwargs)
   File "/Users/dsanders/projects/django-sample/django/db/models/query.py",
 line 1270, in _insert
 return query.get_compiler(using=using).execute_sql(returning_fields)
   File "/Users/dsanders/projects/django-
 sample/django/db/models/sql/compiler.py", line 1416, in execute_sql
 cursor.execute(sql, params)
   File "/Users/dsanders/projects/django-
 sample/django/db/backends/utils.py", line 66, in execute
 return 

Re: [Django] #34523: update_or_create not work in parallel insertion

2023-04-27 Thread Django
#34523: update_or_create not work in parallel insertion
-+-
 Reporter:  gatello-s|Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  4.2
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  update_or_create | Triage Stage:
  TransactionManagementError |  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:  closed => new
 * resolution:  needsinfo =>


-- 
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/01070187c2ad11cc-fce9f726-6d9a-4138-b0a6-38694b1224bf-00%40eu-central-1.amazonses.com.


Re: [Django] #34523: update_or_create not work in parallel insertion

2023-04-27 Thread Django
#34523: update_or_create not work in parallel insertion
-+-
 Reporter:  gatello-s|Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  4.2
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  needsinfo
 Keywords:  update_or_create | Triage Stage:
  TransactionManagementError |  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
 * resolution:   => needsinfo


Comment:

 What kind of exception are you getting?

-- 
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/01070187c2acf129-c3c0f2ae-204c-48f6-920b-043116b57cf5-00%40eu-central-1.amazonses.com.


Re: [Django] #18638: Reverse OneToOne relationship does not save properly.

2023-04-27 Thread Django
#18638: Reverse OneToOne relationship does not save properly.
-+-
 Reporter:  David Hatch  |Owner:  nobody
 Type:  New feature  |   Status:  closed
Component:  Database layer   |  Version:  1.4
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  wontfix
 Keywords:   | Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by NKSM):

 Replying to [comment:5 Aymeric Augustin]:
 > You're seeing the expected behavior. You'd need to call `tag.save()`.
 >
 > The API for 1-to-1 relationships isn't totally symmetrical -- after all
 it isn't at the SQL level.

 This should be documented here:
  https://docs.djangoproject.com/en/dev/topics/db/examples/one_to_one/.

 The way it is now described is confusing.

-- 
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/01070187c2ac237f-4b10287c-fa40-4433-9401-864fcd693357-00%40eu-central-1.amazonses.com.


[Django] #34523: update_or_create not work in parallel insertion

2023-04-27 Thread Django
#34523: update_or_create not work in parallel insertion
-+-
   Reporter:  gatello-s  |  Owner:  nobody
   Type:  Bug| Status:  new
  Component:  Database   |Version:  4.2
  layer (models, ORM)|   Keywords:  update_or_create
   Severity:  Normal |  TransactionManagementError
   Triage Stage: |  Has patch:  0
  Unreviewed |
Needs documentation:  0  |Needs tests:  0
Patch needs improvement:  0  |  Easy pickings:  0
  UI/UX:  0  |
-+-
 I am tests on mariadb 10.5.19 (myisam).
 This test work fine on django-3.2.16

 {{{
 class TransactionManagementErrorTest(TestCase):

 class TestModel(models.Model):
 field = models.IntegerField(null=True)

 class Meta(object):
 db_table = 'test_model_update_or_create'

 class QuerySet(models.QuerySet):
 def create(self, **kwargs):
 super().create(**kwargs)  # simulate parallel insertion
 return super().create(**kwargs)

 class TestModelManager(models.Manager.from_queryset(QuerySet)):
 pass

 objects = TestModelManager()

 def exec_sql(self, sql):
 from django.db import connections, router
 db = router.db_for_write(self.TestModel)
 connection = connections[db]
 connection.cursor().execute(sql)

 def setUp(self):
 super().setUp()
 self.exec_sql(
 'CREATE TABLE IF NOT EXISTS `test_model_update_or_create`
 (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `field` integer NULL);'
 )

 def tearDown(self):
 self.exec_sql(
 'DROP TABLE IF EXISTS `test_model_update_or_create`;'
 )
 super().tearDown()

 def test_update_or_create(self):
 self.TestModel.objects.update_or_create(id=1, defaults={'field':
 2})
 }}}

-- 
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/01070187c2a095aa-ac1d84be-0a70-4ed2-a18e-12e7f0bb0e71-00%40eu-central-1.amazonses.com.


Re: [Django] #34522: PUT/PATCH data is not encoded for multipart/form-data in Django Test Client

2023-04-27 Thread Django
#34522: PUT/PATCH data is not encoded for multipart/form-data in Django Test 
Client
-+-
 Reporter:  Matej Mijoski|Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Testing framework|  Version:  4.2
 Severity:  Normal   |   Resolution:  duplicate
 Keywords:  multipart form   | Triage Stage:
  data, tests, put data encoding |  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
 * resolution:   => duplicate


Comment:

 Yes, it's intentional. Duplicate of #12635 (see comments and related
 discussions for more details.)

-- 
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/01070187c270e211-8fd8fa73-38ad-47b1-b51b-ac08f93dc3f8-00%40eu-central-1.amazonses.com.


Re: [Django] #34522: PUT/PATCH data is not encoded for multipart/form-data in Django Test Client (was: PUT/PATCH data is not encoded for multipart/form-data in Django Test)

2023-04-27 Thread Django
#34522: PUT/PATCH data is not encoded for multipart/form-data in Django Test 
Client
-+-
 Reporter:  Matej Mijoski|Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Testing framework|  Version:  4.2
 Severity:  Normal   |   Resolution:
 Keywords:  multipart form   | Triage Stage:
  data, tests, put data encoding |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

-- 
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/01070187c25f3c9e-32952c1b-5559-4d59-b9d9-5270645eacad-00%40eu-central-1.amazonses.com.


Re: [Django] #34522: PUT/PATCH data is not encoded for multipart/form-data in Django Test

2023-04-27 Thread Django
#34522: PUT/PATCH data is not encoded for multipart/form-data in Django Test
-+-
 Reporter:  MatejMijoski |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Testing framework|  Version:  4.2
 Severity:  Normal   |   Resolution:
 Keywords:  multipart form   | Triage Stage:
  data, tests, put data encoding |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Description changed by MatejMijoski:

Old description:

> I've noticed that the mulipart/form-data is only encoded in the POST
> request of the Django test client and not in the PUT/PATCH requests. Is
> this intentional and if so, why?

New description:

 I've noticed that when making a request using the Django test client with
 a multipart/form-data content type, the data only gets encoded for POST
 requests. Is intentional and if so, why?

--

-- 
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/01070187c25da9ff-e1754b3d-06b8-4fc0-8dc4-ac024e7bd2f5-00%40eu-central-1.amazonses.com.


[Django] #34522: PUT/PATCH data is not encoded for multipart/form-data in Django Test

2023-04-27 Thread Django
#34522: PUT/PATCH data is not encoded for multipart/form-data in Django Test
-+-
   Reporter: |  Owner:  nobody
  MatejMijoski   |
   Type:  Bug| Status:  new
  Component:  Testing|Version:  4.2
  framework  |   Keywords:  multipart form
   Severity:  Normal |  data, tests, put data encoding
   Triage Stage: |  Has patch:  0
  Unreviewed |
Needs documentation:  0  |Needs tests:  0
Patch needs improvement:  0  |  Easy pickings:  0
  UI/UX:  0  |
-+-
 I've noticed that the mulipart/form-data is only encoded in the POST
 request of the Django test client and not in the PUT/PATCH requests. Is
 this intentional and if so, why?

-- 
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/01070187c25bebec-69ad4801-a2df-4448-b9c4-48180fb594ab-00%40eu-central-1.amazonses.com.


Re: [Django] #34515: Translatable URL patterns raise 404 for non-English default language when prefix_default_language=False is used.

2023-04-27 Thread Django
#34515: Translatable URL patterns raise 404 for non-English default language 
when
prefix_default_language=False is used.
-+-
 Reporter:  ab   |Owner:  Sarah
 |  Boyce
 Type:  Bug  |   Status:  assigned
Component:   |  Version:  4.2
  Internationalization   |
 Severity:  Release blocker  |   Resolution:
 Keywords:   | Triage Stage:  Accepted
  internationalization, i18n,|
  prefix_default_language,   |
  i18n_patterns  |
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Mariusz Felisiak):

 [https://forum.djangoproject.com/t/django-behavior-on-translatable-url-
 patterns-i18n-patterns-when-prefix-default-language-false-is-used/20564
 Django forum discussion].

-- 
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/01070187c21e0b42-36779761-2a62-45b4-b577-d2152cb732c9-00%40eu-central-1.amazonses.com.


Re: [Django] #34515: Translatable URL patterns raise 404 for non-English default language when prefix_default_language=False is used.

2023-04-27 Thread Django
#34515: Translatable URL patterns raise 404 for non-English default language 
when
prefix_default_language=False is used.
-+-
 Reporter:  ab   |Owner:  Sarah
 |  Boyce
 Type:  Bug  |   Status:  assigned
Component:   |  Version:  4.2
  Internationalization   |
 Severity:  Release blocker  |   Resolution:
 Keywords:   | Triage Stage:  Accepted
  internationalization, i18n,|
  prefix_default_language,   |
  i18n_patterns  |
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by ab):

 Just to keep track of the current work on this issue, there is a
 discussion about how django should behave here:
 https://github.com/django/django/pull/16797#issuecomment-1524958085

 As suggested by Sarah, I'll post to django-developers for a wider range of
 opinions.

-- 
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/01070187c1dae3a9-51042bb4-d7ea-47dc-a8a9-2f30605f11bf-00%40eu-central-1.amazonses.com.


Re: [Django] #34521: Use __slots__ for template Node classes

2023-04-27 Thread Django
#34521: Use __slots__ for template Node classes
-+-
 Reporter:  Adam Johnson |Owner:  Adam
 Type:   |  Johnson
  Cleanup/optimization   |   Status:  assigned
Component:  Template system  |  Version:  dev
 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 Mariusz Felisiak):

 * owner:  nobody => Adam Johnson
 * status:  new => assigned
 * stage:  Unreviewed => Accepted


Comment:

 Thanks. Tentatively 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/01070187c189a383-201a8850-9c31-42c2-9bb7-a497933ddc48-00%40eu-central-1.amazonses.com.


Re: [Django] #34521: Use __slots__ for template Node classes

2023-04-27 Thread Django
#34521: Use __slots__ for template Node classes
-+-
 Reporter:  Adam Johnson |Owner:  nobody
 Type:   |   Status:  new
  Cleanup/optimization   |
Component:  Template system  |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:
 |  Unreviewed
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Description changed by Adam Johnson:

Old description:

> Declaring __slots__ reduces the memory footprint of a class, and can lead
> to performance gains due to less data fetching by the CPU.
>
> #12826 proposed adding __slots__ to many classes but was closed with the
> proposal to do so on a case-by-case basis.
>
> #33474 added __slots__ to `Variable` and related classes, showing memory
> reductions and performance gains.
>
> I propose adding __slots__ to more template classes to further save
> memory (Template, Token, Lexer, and the Node classes). This change leads
> to about a 1% improvement in template rendering time, using this
> benchmark script:
>
> {{{
> import django
> from django.conf import settings
> from django.template import Context
> from django.template import Template
>
> settings.configure(
> TEMPLATES=[{"BACKEND":
> "django.template.backends.django.DjangoTemplates"}]
> )
> django.setup()
>
> template = Template("{% if x %}{{ x }}{% endif %}" * 1_000)
> context = Context({"x": "abc"})
> for i in range(1_000):
> template.render(context)
> }}}
>
> And invoking [hyperfine](https://github.com/sharkdp/hyperfine) like so,
> with Python 3.11.2:
>
> {{{
> $ hyperfine \
>   -N --warmup 1 \
>   --prepare 'git switch -d 7d0e566208' \
>   'python benchmark.py' \
>   --prepare 'git switch optimize_templates' \
>   'python benchmark.py'
> Benchmark 1: python benchmark.py
>   Time (mean ± σ):  2.006 s ±  0.007 s[User: 1.968 s, System:
> 0.035 s]
>   Range (min … max):1.995 s …  2.013 s10 runs
>
> Benchmark 2: python benchmark.py
>   Time (mean ± σ):  1.993 s ±  0.008 s[User: 1.958 s, System:
> 0.034 s]
>   Range (min … max):1.984 s …  2.012 s10 runs
>
> Summary
>   'python benchmark.py' ran
> 1.01 ± 0.01 times faster than 'python benchmark.py'
> }}}

New description:

 Declaring __slots__ reduces the memory footprint of a class, and can lead
 to performance gains due to less data fetching by the CPU.

 #12826 proposed adding __slots__ to many classes but was closed with the
 proposal to do so on a case-by-case basis.

 #33474 added __slots__ to `Variable` and related classes, showing memory
 reductions and performance gains.

 I propose adding __slots__ to more template classes to further save memory
 (Template, Token, Lexer, and the Node classes). This change leads to 1-2%
 improvement in template rendering time, using this benchmark script:

 {{{
 import django
 from django.conf import settings
 from django.template import Context
 from django.template import Template

 settings.configure(
 TEMPLATES=[{"BACKEND":
 "django.template.backends.django.DjangoTemplates"}]
 )
 django.setup()

 template = Template("{% if x %}{{ x }}{% endif %}" * 1_000)
 context = Context({"x": "abc"})
 for i in range(1_000):
 template.render(context)
 }}}

 And invoking [hyperfine](https://github.com/sharkdp/hyperfine) like so,
 with Python 3.11.2:

 {{{
 $ hyperfine \
   -N --warmup 1 \
   --prepare 'git switch -d 7d0e566208' \
   'python benchmark.py' \
   --prepare 'git switch ticket_34521_optimize_templates' \
   'python benchmark.py'
 Benchmark 1: python benchmark.py
   Time (mean ± σ):  2.028 s ±  0.042 s[User: 1.990 s, System:
 0.035 s]
   Range (min … max):1.997 s …  2.116 s10 runs

 Benchmark 2: python benchmark.py
   Time (mean ± σ):  1.985 s ±  0.007 s[User: 1.950 s, System:
 0.033 s]
   Range (min … max):1.976 s …  1.997 s10 runs

 Summary
   'python benchmark.py' ran
 1.02 ± 0.02 times faster than 'python benchmark.py'
 }}}

 (I decided not to use djangobench since it's not well maintained, and
 doesn't do such great stats as hyperfine.)

--

-- 
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 

Re: [Django] #34521: Use __slots__ for template Node classes

2023-04-27 Thread Django
#34521: Use __slots__ for template Node classes
-+-
 Reporter:  Adam Johnson |Owner:  nobody
 Type:   |   Status:  new
  Cleanup/optimization   |
Component:  Template system  |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:
 |  Unreviewed
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Description changed by Adam Johnson:

Old description:

> Declaring __slots__ reduces the memory footprint of a class, and can lead
> to performance gains due to less data fetching by the CPU.
>
> #12826 proposed adding __slots__ to many classes but was closed with the
> proposal to do so on a case-by-case basis.
>
> #33474 added __slots__ to `Variable` and related classes, showing memory
> reductions and performance gains.
>
> I propose adding __slots__ to all template Node classes to save further
> memory. This leads to about a 1% improvement in template rendering time,
> using this benchmark script:
>
> {{{
> import django
> from django.conf import settings
> from django.template import Context
> from django.template import Template
>
> settings.configure(
> TEMPLATES=[{"BACKEND":
> "django.template.backends.django.DjangoTemplates"}]
> )
> django.setup()
>
> template = Template("{% if x %}{{ x }}{% endif %}" * 1_000)
> context = Context({"x": "abc"})
> for i in range(1_000):
> template.render(context)
> }}}
>
> And invoking [hyperfine](https://github.com/sharkdp/hyperfine) like so:
>
> {{{
> $ hyperfine \
>   -N --warmup 1 \
>   --prepare 'git switch -d 7d0e566208' \
>   'python benchmark.py' \
>   --prepare 'git switch optimize_templates' \
>   'python benchmark.py'
> Benchmark 1: python benchmark.py
>   Time (mean ± σ):  2.006 s ±  0.007 s[User: 1.968 s, System:
> 0.035 s]
>   Range (min … max):1.995 s …  2.013 s10 runs
>
> Benchmark 2: python benchmark.py
>   Time (mean ± σ):  1.993 s ±  0.008 s[User: 1.958 s, System:
> 0.034 s]
>   Range (min … max):1.984 s …  2.012 s10 runs
>
> Summary
>   'python benchmark.py' ran
> 1.01 ± 0.01 times faster than 'python benchmark.py'
> }}}

New description:

 Declaring __slots__ reduces the memory footprint of a class, and can lead
 to performance gains due to less data fetching by the CPU.

 #12826 proposed adding __slots__ to many classes but was closed with the
 proposal to do so on a case-by-case basis.

 #33474 added __slots__ to `Variable` and related classes, showing memory
 reductions and performance gains.

 I propose adding __slots__ to more template classes to further save memory
 (Template, Token, Lexer, and the Node classes). This change leads to about
 a 1% improvement in template rendering time, using this benchmark script:

 {{{
 import django
 from django.conf import settings
 from django.template import Context
 from django.template import Template

 settings.configure(
 TEMPLATES=[{"BACKEND":
 "django.template.backends.django.DjangoTemplates"}]
 )
 django.setup()

 template = Template("{% if x %}{{ x }}{% endif %}" * 1_000)
 context = Context({"x": "abc"})
 for i in range(1_000):
 template.render(context)
 }}}

 And invoking [hyperfine](https://github.com/sharkdp/hyperfine) like so,
 with Python 3.11.2:

 {{{
 $ hyperfine \
   -N --warmup 1 \
   --prepare 'git switch -d 7d0e566208' \
   'python benchmark.py' \
   --prepare 'git switch optimize_templates' \
   'python benchmark.py'
 Benchmark 1: python benchmark.py
   Time (mean ± σ):  2.006 s ±  0.007 s[User: 1.968 s, System:
 0.035 s]
   Range (min … max):1.995 s …  2.013 s10 runs

 Benchmark 2: python benchmark.py
   Time (mean ± σ):  1.993 s ±  0.008 s[User: 1.958 s, System:
 0.034 s]
   Range (min … max):1.984 s …  2.012 s10 runs

 Summary
   'python benchmark.py' ran
 1.01 ± 0.01 times faster than 'python benchmark.py'
 }}}

--

-- 
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/01070187c1768d9e-aa046499-fee0-4e8c-a74b-d7fc80bd43f4-00%40eu-central-1.amazonses.com.


[Django] #34521: Use __slots__ for template Node classes

2023-04-27 Thread Django
#34521: Use __slots__ for template Node classes
+
   Reporter:  Adam Johnson  |  Owner:  nobody
   Type:  Cleanup/optimization  | Status:  new
  Component:  Template system   |Version:  dev
   Severity:  Normal|   Keywords:
   Triage Stage:  Unreviewed|  Has patch:  1
Needs documentation:  0 |Needs tests:  0
Patch needs improvement:  0 |  Easy pickings:  0
  UI/UX:  0 |
+
 Declaring __slots__ reduces the memory footprint of a class, and can lead
 to performance gains due to less data fetching by the CPU.

 #12826 proposed adding __slots__ to many classes but was closed with the
 proposal to do so on a case-by-case basis.

 #33474 added __slots__ to `Variable` and related classes, showing memory
 reductions and performance gains.

 I propose adding __slots__ to all template Node classes to save further
 memory. This leads to about a 1% improvement in template rendering time,
 using this benchmark script:

 {{{
 import django
 from django.conf import settings
 from django.template import Context
 from django.template import Template

 settings.configure(
 TEMPLATES=[{"BACKEND":
 "django.template.backends.django.DjangoTemplates"}]
 )
 django.setup()

 template = Template("{% if x %}{{ x }}{% endif %}" * 1_000)
 context = Context({"x": "abc"})
 for i in range(1_000):
 template.render(context)
 }}}

 And invoking [hyperfine](https://github.com/sharkdp/hyperfine) like so:

 {{{
 $ hyperfine \
   -N --warmup 1 \
   --prepare 'git switch -d 7d0e566208' \
   'python benchmark.py' \
   --prepare 'git switch optimize_templates' \
   'python benchmark.py'
 Benchmark 1: python benchmark.py
   Time (mean ± σ):  2.006 s ±  0.007 s[User: 1.968 s, System:
 0.035 s]
   Range (min … max):1.995 s …  2.013 s10 runs

 Benchmark 2: python benchmark.py
   Time (mean ± σ):  1.993 s ±  0.008 s[User: 1.958 s, System:
 0.034 s]
   Range (min … max):1.984 s …  2.012 s10 runs

 Summary
   'python benchmark.py' ran
 1.01 ± 0.01 times faster than 'python benchmark.py'
 }}}

-- 
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/01070187c174ecb8-2800afec-d8ee-411e-a364-0d0a85568d16-00%40eu-central-1.amazonses.com.


Re: [Django] #34380: Make URLField assume "https".

2023-04-27 Thread Django
#34380: Make URLField assume "https".
-+-
 Reporter:  Coen van der Kamp|Owner:  Coen van
 Type:   |  der Kamp
  Cleanup/optimization   |   Status:  assigned
Component:  Forms|  Version:  4.1
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * needs_better_patch:  1 => 0
 * stage:  Accepted => Ready for checkin
 * needs_docs:  1 => 0


-- 
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/01070187c16973ac-e45c2f7a-7acc-4ef3-9067-0df8d86c9111-00%40eu-central-1.amazonses.com.