Re: [Django] #34881: migrate crashes when renaming model referenced twice by ManyToManyField.through model on SQLite.

2023-10-24 Thread Django
#34881: migrate crashes when renaming model referenced twice by
ManyToManyField.through model on SQLite.
+
 Reporter:  dennisvang  |Owner:  Jase Hackman
 Type:  Bug |   Status:  assigned
Component:  Migrations  |  Version:  dev
 Severity:  Normal  |   Resolution:
 Keywords:  sqlite  | Triage Stage:  Accepted
Has patch:  0   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+

Comment (by Simon Charette):

 Thanks for working on this patch during DjangConUS Jase!

 From reviewing your changes and tests I get a sense that there might be an
 even less invasive way to address this particular issue.

 The crux of the problem here, as you've identified it, is the SQLite
 backend needs to rebuild the table entirely and it cannot be done from an
 old representation of the model iteratively.

 By the time `alter_field` is called the columns of the tables related to
 the one being renamed are already altered in the database (a `RENAME`
 operation repoints all referencing columns) so it should be safe to
 provide the model originating from `to_state`
 
[https://github.com/django/django/blob/fdd1323b9c83e56184e0c992af8faf8d54327775/django/db/migrations/operations/models.py#L421
 like we do when dealing with self-referencing related objects].

 By retrieving the model meant to be passed to `alter_field` from to
 `to_state`

 {{{#!diff
 diff --git a/django/db/migrations/operations/models.py
 b/django/db/migrations/operations/models.py
 index d616cafb45..83e3fb772d 100644
 --- a/django/db/migrations/operations/models.py
 +++ b/django/db/migrations/operations/models.py
 @@ -421,11 +421,11 @@ def database_forwards(self, app_label,
 schema_editor, from_state, to_state):
  model = new_model
  related_key = (app_label, self.new_name_lower)
  else:
 -model = related_object.related_model
  related_key = (
  related_object.related_model._meta.app_label,
  related_object.related_model._meta.model_name,
  )
 +model = to_state.apps.get_model(*related_key)
  to_field =
 to_state.apps.get_model(*related_key)._meta.get_field(
  related_object.field.name
  )
 }}}

 The tests seem to be passing.

 I think that your work on `alter_fields` might be beneficial to support
 tickets like #24203 but might not be strictly necessary to address this
 particular issue.

-- 
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/0107018b653a515e-eddf419d-f1bc-4b30-9b16-82459f63a824-00%40eu-central-1.amazonses.com.


Re: [Django] #34925: refresh_from_db() will not iterate through all of the fields listed in the 'fields' parameter.

2023-10-24 Thread Django
#34925: refresh_from_db() will not iterate through all of the fields listed in 
the
'fields' parameter.
-+-
 Reporter:  Andrew Cordery   |Owner:  Asfand
 |  Yar Khan
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  5.0
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-

Comment (by Asfand Yar Khan):

 Was able to reproduce this on my end.

-- 
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/0107018b6435ee26-fdf54e8b-d67d-48aa-bda4-7b4b14559d87-00%40eu-central-1.amazonses.com.


Re: [Django] #34925: refresh_from_db() will not iterate through all of the fields listed in the 'fields' parameter.

2023-10-24 Thread Django
#34925: refresh_from_db() will not iterate through all of the fields listed in 
the
'fields' parameter.
-+-
 Reporter:  Andrew Cordery   |Owner:  Asfand
 |  Yar Khan
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  5.0
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-
Changes (by Simon Charette):

 * version:  4.2 => 5.0
 * stage:  Unreviewed => Accepted


Comment:

 Wow it's surprising that this flew under the radar for so long. The bug
 has been around since we introduced prefetched relationship clearing in
 #29625.

 We should definitely not alter the provided `fields` and obviously not
 remove members while iterating over it.

-- 
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/0107018b63f79422-fa0ecaea-1074-4b07-9fd9-1fb79c7dbe48-00%40eu-central-1.amazonses.com.


Re: [Django] #34925: refresh_from_db() will not iterate through all of the fields listed in the 'fields' parameter.

2023-10-24 Thread Django
#34925: refresh_from_db() will not iterate through all of the fields listed in 
the
'fields' parameter.
-+-
 Reporter:  Andrew Cordery   |Owner:  Asfand
 |  Yar Khan
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  4.2
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-
Changes (by Asfand Yar Khan):

 * owner:  nobody => Asfand Yar Khan
 * 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/0107018b63ef3bdb-555f0441-abec-44ea-9141-303e053b9919-00%40eu-central-1.amazonses.com.


Re: [Django] #34926: Missing model after squashing

2023-10-24 Thread Django
#34926: Missing model after squashing
+--
 Reporter:  Sebastian Jekutsch  |Owner:  nobody
 Type:  Bug |   Status:  closed
Component:  Migrations  |  Version:  4.2
 Severity:  Normal  |   Resolution:  invalid
 Keywords:  | Triage Stage:  Unreviewed
Has patch:  0   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+--
Changes (by Sebastian Jekutsch):

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


Comment:

 Ok, seems I have differences locally.

-- 
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/0107018b637056bf-895d9576-3cdd-42b2-a2b3-3a9bd56eb377-00%40eu-central-1.amazonses.com.


Re: [Django] #34926: Missing model after squashing

2023-10-24 Thread Django
#34926: Missing model after squashing
+--
 Reporter:  Sebastian Jekutsch  |Owner:  nobody
 Type:  Bug |   Status:  new
Component:  Migrations  |  Version:  4.2
 Severity:  Normal  |   Resolution:
 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 Mariusz Felisiak):

 Replying to [comment:3 Sebastian Jekutsch]:
 > Right, but it's below its first reference in model Topic within the
 script, so an initial database migration will raise an "ValueError:
 Related model 'knowledgebase.activity' cannot be resolved".
 > (Apologize for not stating the problem more specific.)

 That is also not true:
 {{{
 migrations.CreateModel(
 name="Activity",
 fields=[
 (
 "id",
 models.BigAutoField(
 auto_created=True,
 primary_key=True,
 serialize=False,
 verbose_name="ID",
 ),
 ),
 ("name", models.CharField(max_length=50)),
 (
 "members",
 models.ManyToManyField(
 blank=True,
 related_name="memberships",
 to="knowledgebase.activity",
 ),
 ),
 ("alternative_names", models.CharField(blank=True,
 max_length=250)),
 ],
 options={
 "verbose_name": "Activity",
 "verbose_name_plural": "Activities",
 "ordering":
 [django.db.models.functions.text.Lower("name")],
 },
 ),
 migrations.AddField(
 model_name="topic",
 name="activities",
 field=models.ManyToManyField(
 blank=True, related_name="activities",
 to="knowledgebase.activity"
 ),
 ),
 }}}

 Please see TicketClosingReasons/UseSupportChannels for ways to get help
 and don't use Trac as a support channel.

-- 
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/0107018b635fd98f-5f8f54dc-0a4b-47b7-bf1d-f97dc411c4e0-00%40eu-central-1.amazonses.com.


Re: [Django] #34926: Missing model after squashing

2023-10-24 Thread Django
#34926: Missing model after squashing
+--
 Reporter:  Sebastian Jekutsch  |Owner:  nobody
 Type:  Bug |   Status:  new
Component:  Migrations  |  Version:  4.2
 Severity:  Normal  |   Resolution:
 Keywords:  | Triage Stage:  Unreviewed
Has patch:  0   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+--
Changes (by Sebastian Jekutsch):

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


Comment:

 Right, but it's below its first reference in model Topic within the
 script, so an initial database migration will raise an "ValueError:
 Related model 'knowledgebase.activity' cannot be resolved".
 (Apologize for not stating the problem more specific.)

-- 
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/0107018b635465b9-433862dc-1a59-4b89-bd3a-8bd3fe4ae863-00%40eu-central-1.amazonses.com.


Re: [Django] #34926: Missing model after squashing

2023-10-24 Thread Django
#34926: Missing model after squashing
+--
 Reporter:  Sebastian Jekutsch  |Owner:  nobody
 Type:  Bug |   Status:  closed
Component:  Migrations  |  Version:  4.2
 Severity:  Normal  |   Resolution:  invalid
 Keywords:  | 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
 * resolution:   => invalid


Comment:

 `Activity` is in the squashed migration.

-- 
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/0107018b62de1c78-89ad133e-2775-4137-ae8c-dffceeca1f0f-00%40eu-central-1.amazonses.com.


Re: [Django] #34926: Missing model after squashing

2023-10-24 Thread Django
#34926: Missing model after squashing
+--
 Reporter:  Sebastian Jekutsch  |Owner:  nobody
 Type:  Bug |   Status:  new
Component:  Migrations  |  Version:  4.2
 Severity:  Normal  |   Resolution:
 Keywords:  | Triage Stage:  Unreviewed
Has patch:  0   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+--
Description changed by Sebastian Jekutsch:

Old description:

> Sorry for an unspecific subject and not searching for duplicates due to
> lack of knowledge, understanding and time.
>
> As an excerpt from #34924 which has been correctly closed as duplicate
> for two of its issues, the third one remains unresolved, as far as I see.
> I reopen it with this new report.
>
> Based on the attachments
> 1. Zip of single migrations 0001 to 0116
> 2. Resulting squashed migration file of "manage.py squashmigrations
> knowledgebase 0116"
> 3. models.py at the end of 0116
> I found that model Activity has errorneously disappeared completely in
> the squashed migration file. It has even not been detected by a new
> makemigrations run for cross-check.

New description:

 Sorry for an unspecific subject and not searching for duplicates due to
 lack of knowledge, understanding and time.

 As an excerpt from #34924 which has been correctly closed as duplicate for
 two of its issues, the third one remains unresolved, as far as I see. I
 reopen it with this new report.

 Based on the attachments
 1. Zip of single migrations 0001 to 0116
 2. Resulting squashed migration file of "manage.py squashmigrations
 knowledgebase 0116"
 3. models.py at the end of 0116
 within #34924,
 I found that model Activity has errorneously disappeared completely in the
 squashed migration file. It has even not been detected by a new
 makemigrations run for cross-check.

--

-- 
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/0107018b62aebe68-e383ece9-7ffb-414a-8987-0bba03e58c48-00%40eu-central-1.amazonses.com.


Re: [Django] #34923: MESSAGE_TAGS ignored in 5.0a1

2023-10-24 Thread Django
#34923: MESSAGE_TAGS ignored in 5.0a1
-+-
 Reporter:  James Gillard|Owner:  Mariusz
 |  Felisiak
 Type:  Bug  |   Status:  closed
Component:  contrib.messages |  Version:  5.0
 Severity:  Release blocker  |   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
-+-

Comment (by Natalia <124304+nessita@…>):

 In [changeset:"00805ff4369efb269a825880ec4589fc14efb82d" 00805ff]:
 {{{
 #!CommitTicketReference repository=""
 revision="00805ff4369efb269a825880ec4589fc14efb82d"
 [5.0.x] Fixed #34923 -- Avoided initializing LEVEL_TAGS when importing
 django.contrib.messages.

 Regression in b7fe36ad37fb18c4bc7932c0aec6ae4f299b9622.

 Thanks James Gillard for the report.

 Backport of 311718feb5f1fb9ff794bbac0cda48cfc3410de8 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/0107018b62ad268c-44c70714-7cbf-48b8-816d-ab16d228c5f5-00%40eu-central-1.amazonses.com.


[Django] #34926: Missing model after squashing

2023-10-24 Thread Django
#34926: Missing model after squashing
--+
   Reporter:  Sebastian Jekutsch  |  Owner:  nobody
   Type:  Bug | Status:  new
  Component:  Migrations  |Version:  4.2
   Severity:  Normal  |   Keywords:
   Triage Stage:  Unreviewed  |  Has patch:  0
Needs documentation:  0   |Needs tests:  0
Patch needs improvement:  0   |  Easy pickings:  0
  UI/UX:  0   |
--+
 Sorry for an unspecific subject and not searching for duplicates due to
 lack of knowledge, understanding and time.

 As an excerpt from #34924 which has been correctly closed as duplicate for
 two of its issues, the third one remains unresolved, as far as I see. I
 reopen it with this new report.

 Based on the attachments
 1. Zip of single migrations 0001 to 0116
 2. Resulting squashed migration file of "manage.py squashmigrations
 knowledgebase 0116"
 3. models.py at the end of 0116
 I found that model Activity has errorneously disappeared completely in the
 squashed migration file. It has even not been detected by a new
 makemigrations run for cross-check.

-- 
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/0107018b62acb52f-4825f0dd-614f-4c70-8b86-3a19eed96e73-00%40eu-central-1.amazonses.com.


Re: [Django] #34923: MESSAGE_TAGS ignored in 5.0a1

2023-10-24 Thread Django
#34923: MESSAGE_TAGS ignored in 5.0a1
-+-
 Reporter:  James Gillard|Owner:  Mariusz
 |  Felisiak
 Type:  Bug  |   Status:  closed
Component:  contrib.messages |  Version:  5.0
 Severity:  Release blocker  |   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 Natalia <124304+nessita@…>):

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


Comment:

 In [changeset:"311718feb5f1fb9ff794bbac0cda48cfc3410de8" 311718fe]:
 {{{
 #!CommitTicketReference repository=""
 revision="311718feb5f1fb9ff794bbac0cda48cfc3410de8"
 Fixed #34923 -- Avoided initializing LEVEL_TAGS when importing
 django.contrib.messages.

 Regression in b7fe36ad37fb18c4bc7932c0aec6ae4f299b9622.

 Thanks James Gillard for the report.
 }}}

-- 
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/0107018b62abf521-5102f123-52db-44d9-b9fd-1bb27756beae-00%40eu-central-1.amazonses.com.


Re: [Django] #34923: MESSAGE_TAGS ignored in 5.0a1

2023-10-24 Thread Django
#34923: MESSAGE_TAGS ignored in 5.0a1
-+-
 Reporter:  James Gillard|Owner:  Mariusz
 |  Felisiak
 Type:  Bug  |   Status:  assigned
Component:  contrib.messages |  Version:  5.0
 Severity:  Release blocker  |   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 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/0107018b62a90a72-cb2a802a-6a10-4c5b-83de-4ecbbf8a1cce-00%40eu-central-1.amazonses.com.


[Django] #34925: refresh_from_db() will not iterate through all of the fields listed in the 'fields' parameter.

2023-10-24 Thread Django
#34925: refresh_from_db() will not iterate through all of the fields listed in 
the
'fields' parameter.
-+-
   Reporter:  Andrew |  Owner:  nobody
  Cordery|
   Type:  Bug| Status:  new
  Component:  Database   |Version:  4.2
  layer (models, ORM)|
   Severity:  Normal |   Keywords:
   Triage Stage: |  Has patch:  0
  Unreviewed |
Needs documentation:  0  |Needs tests:  0
Patch needs improvement:  0  |  Easy pickings:  1
  UI/UX:  0  |
-+-
 This one was killing me today.  If you pass the 'fields' parameter to
 {{{refresh_from_db}}} it is supposed to only remove those fields from
 {{{_prefetched_objects_cache}}} as described in the docs:
 
https://docs.djangoproject.com/en/4.2/ref/models/instances/#django.db.models.Model.refresh_from_db.

 Unfortunately, it modifies the 'fields' variable as it iterates through
 it:

 ''Line 694 of django.db.models.base.py:''
 {{{
 for field in fields:
 if field in prefetched_objects_cache:
 del prefetched_objects_cache[field]
 fields.remove(field)
 }}}

 Modifying the list that we are iterating over causes some list items to be
 skipped.  For example here we would expected to see 'a', 'b', and 'c',
 removed from dict {{{d}}} but 'b' is skipped:

 {{{
 In [8]: d = dict(a=1,b=2, c=3)

 In [9]: fields = ['a','b','c']

 In [10]: for f in fields:
 ...: print(f)
 ...: if f in d:
 ...: del d[f]
 ...: fields.remove(f)
 ...:
 a
 c

 In [11]: fields
 Out[11]: ['b']
 In [12]: d
 Out[12]: {'b': 2}

 }}}

 I beieve that all that needs to be done to correct this is to create a
 copy of the list by wrapping fields in list(), like so:

 {{{
 In [13]: fields = ['a','b','c']

 In [14]: d=dict(a=1,b=2, c=3)

 In [15]: for f in list(fields):
 ...: print(f)
 ...: if f in d:
 ...: del d[f]
 ...: fields.remove(f)
 ...:
 a
 b
 c

 In [16]: d
 Out[16]: {}

 In [17]: fields
 Out[17]: []
 }}}

 Therefore as far as I can tell the fix to the django code would be as easy
 as wrapping fields in list():

 ''Line 694 of django.db.models.base.py:'' modified
 {{{
 for field in list(fields):
 if field in prefetched_objects_cache:
 del prefetched_objects_cache[field]
 fields.remove(field)
 }}}

-- 
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/0107018b626f0809-ba4b776b-7246-44df-a5a9-c220ae15402f-00%40eu-central-1.amazonses.com.


Re: [Django] #34907: loaddata crashes on objects with natural keys when don't exist on passed database.

2023-10-24 Thread Django
#34907: loaddata crashes on objects with natural keys when don't exist on passed
database.
-+-
 Reporter:  Florian  |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Core |  Version:  4.2
  (Serialization)|
 Severity:  Normal   |   Resolution:
 Keywords:  natural key, multi-  | Triage Stage:  Accepted
  db, loaddata   |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Florian):

 Thanks for looking into it. The patch seems to fix it for me (filling in
 some small details like importing the router):

 {{{#!diff
 diff --git a/django/core/serializers/python.py
 b/django/core/serializers/python.py
 index 7ec894aa00..2ef5a1765a 100644
 --- a/django/core/serializers/python.py
 +++ b/django/core/serializers/python.py
 @@ -6,7 +6,7 @@ other serializers.

  from django.apps import apps
  from django.core.serializers import base
 -from django.db import DEFAULT_DB_ALIAS, models
 +from django.db import DEFAULT_DB_ALIAS, models, router
  from django.utils.encoding import is_protected_type


 @@ -118,6 +118,8 @@ def Deserializer(
  else:
  raise
  data = {}
 +if not router.allow_migrate(using, Model):
 +continue
  if "pk" in d:
  try:
  data[Model._meta.pk.attname] =
 Model._meta.pk.to_python(d.get("pk"))

 }}}

 The test script outputs 'Ok' when running all tests with this patch
 applied.

 I can't really figure out what would be a logical unit test for the bug.
 I've been looking at `tests/serializers/test_natural.py` for inspiration.
 But I guess I'm not familiar enough with this part to come up with a good
 test case that fails without this patch. What I've tried is modifying
 `natural_key_test` to use a different database (modifications marked with
 comments):

 {{{
 class TestRouter:
 def allow_migrate(self, db, app_label, model_name=None, **hints):
 return False


 @override_settings(DATABASE_ROUTES=[TestRouter])  # added router
 def natural_key_test_multidb(self, format):
 book1 = {
 "data": "978-1590597255",
 "title": "The Definitive Guide to Django: Web Development Done
 Right",
 }
 book2 = {"data": "978-1590599969", "title": "Practical Django
 Projects"}

 # Create the books.
 adrian = NaturalKeyAnchor.objects.create(**book1)
 james = NaturalKeyAnchor.objects.create(**book2)

 # Serialize the books.
 string_data = serializers.serialize(
 format,
 NaturalKeyAnchor.objects.all(),
 indent=2,
 use_natural_foreign_keys=True,
 use_natural_primary_keys=True,
 )

 # Delete one book (to prove that the natural key generation will only
 # restore the primary keys of books found in the database via the
 # get_natural_key manager method).
 james.delete()

 # Deserialize and test.
 books = list(serializers.deserialize(format, string_data,
 using='other'))  # added using
 self.assertCountEqual(
 [(book.object.title, book.object.pk) for book in books],
 [
 (book1["title"], None),  # None i.s.o. adrian.pk
 (book2["title"], None),
 ],
 )
 }}}

 It feels natural to me that `None` is returned when using a different
 database in which the object doesn't exist. This test succeeds already
 without the patch. I guess what's missing is that the router is not used
 when setting up the database, but I'm currently somewhat lost in getting
 it to do that. Any hints?

 I'm going to look into it some more tomorrow.

-- 
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/0107018b6215076f-977cd934-ef7f-4be7-adc3-e2f5e90e4cff-00%40eu-central-1.amazonses.com.


Re: [Django] #10941: Add a templatetag to generate querystrings

2023-10-24 Thread Django
#10941: Add a templatetag to generate querystrings
-+---
 Reporter:  Ben Spaulding|Owner:  Tom Carrick
 Type:  New feature  |   Status:  assigned
Component:  Template system  |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:  pagination   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+---
Changes (by Tom Carrick):

 * needs_better_patch:  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/0107018b6167da7c-1e7016ef-c1d8-4c08-a24e-6aed32b404e8-00%40eu-central-1.amazonses.com.


Re: [Django] #34923: MESSAGE_TAGS ignored in 5.0a1

2023-10-24 Thread Django
#34923: MESSAGE_TAGS ignored in 5.0a1
-+-
 Reporter:  James Gillard|Owner:  Mariusz
 |  Felisiak
 Type:  Bug  |   Status:  assigned
Component:  contrib.messages |  Version:  5.0
 Severity:  Release blocker  |   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):

 * has_patch:  0 => 1


Comment:

 [https://github.com/django/django/pull/17407 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/0107018b60b66243-5bf4eac4-0746-49fd-a5ac-43f7441cd169-00%40eu-central-1.amazonses.com.


Re: [Django] #34919: Missing scope attribute in admin doc table headers. (was: Missing scope attribute in admin doc table headers)

2023-10-24 Thread Django
#34919: Missing scope attribute in admin doc table headers.
-+-
 Reporter:  Louis-Cloud  |Owner:  Louis-
 |  Cloud
 Type:  Bug  |   Status:  assigned
Component:  contrib.admindocs|  Version:  4.2
 Severity:  Normal   |   Resolution:
 Keywords:  table, scope,| Triage Stage:  Accepted
  screenreader, accessibility|
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  1
-+-
Changes (by Mariusz Felisiak):

 * 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/0107018b60878633-5216ebc9-f0d7-450a-951c-bf383ab53075-00%40eu-central-1.amazonses.com.


Re: [Django] #34924: Example for squashmigration not working properly

2023-10-24 Thread Django
#34924: Example for squashmigration not working properly
+--
 Reporter:  Sebastian Jekutsch  |Owner:  nobody
 Type:  Bug |   Status:  closed
Component:  Migrations  |  Version:  4.2
 Severity:  Normal  |   Resolution:  duplicate
 Keywords:  | 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
 * resolution:   => duplicate


Comment:

 Thanks for this report, it's a duplicate of #26223 (`document.created_at`,
 `document.abstract`, `evidence.reference`) and #32263 (`actor.category`).

-- 
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/0107018b608245bf-43b152a1-785d-40a9-8ce4-70bd53ea13ad-00%40eu-central-1.amazonses.com.