Re: [Django] #34417: AlterField migration on ForeignKey field re-creates foreign key constraints unnecessarily

2023-03-16 Thread Django
#34417: AlterField migration on ForeignKey field re-creates foreign key 
constraints
unnecessarily
--+
 Reporter:  Ömer Faruk Abacı  |Owner:  nobody
 Type:  Cleanup/optimization  |   Status:  new
Component:  Migrations|  Version:  4.1
 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 Simon Charette):

 * stage:  Unreviewed => Accepted


Comment:

 Dropping the foreign key and recreating it [https://dbfiddle.uk/hgRUL6q6
 is effectively not necessary on PostgreSQL] but
 [https://dbfiddle.uk/OJ6KqwrW it is on MySQL] as this backend requires an
 index on the ''referencing'' side of the relation and will silently
 default to using an existing one if its present (see #31335 for more
 details).

 Given the contention issues associated with dropping a foreign key on
 PostgreSQL I think it's a worthy investment to try to make things better
 on databases that are not affected by this quirk.

 Would you like
 [https://docs.djangoproject.com/en/4.1/internals/contributing/writing-code
 /submitting-patches/ to work on a patch]? The
 
[https://github.com/django/django/blob/d2b688b966f5d30414899549412d370e1317ddb8/django/db/backends/base/schema.py#L852-L1198
 alter_field method is where you want to start looking] and you'll likely
 need a feature flag to denote that foreign keys must be dropped or not
 based on the backend.

-- 
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/01070186ebe77d9a-a3a383db-6999-46b1-854d-b1c9031be390-00%40eu-central-1.amazonses.com.


[Django] #34417: AlterField migration on ForeignKey field re-creates foreign key constraints unnecessarily

2023-03-16 Thread Django
#34417: AlterField migration on ForeignKey field re-creates foreign key 
constraints
unnecessarily
+
   Reporter:  Ömer Faruk Abacı  |  Owner:  nobody
   Type:  Cleanup/optimization  | Status:  new
  Component:  Migrations|Version:  4.1
   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 |
+
 Let's assume that we have the following models:

 {{{
 class Bar(models.Model):
 pass

 class Foo(models.Model):
 bar = models.ForeignKey(Bar, related_name="foos",
 on_delete=models.CASCADE)
 }}}

 The migration that creates these models will add an index to the `bar`
 field of `Foo` model, this is well-documented and there is no problem up
 until now. But when we do the following change to drop the index on the
 ForeignKey field:


 {{{
 class Foo(models.Model):
 bar = models.ForeignKey(..., db_index=False)
 }}}

 Then we have a migration that results in the following SQL statement:


 {{{
 BEGIN;
 --
 -- Alter field bar on foo
 --
 SET CONSTRAINTS "foos_foo_bar_id_efb062ad_fk_foos_bar_id" IMMEDIATE;
 ALTER TABLE "foos_foo"
 DROP CONSTRAINT "foos_foo_bar_id_efb062ad_fk_foos_bar_id";

 DROP INDEX IF EXISTS "foos_foo_bar_id_efb062ad";

 ALTER TABLE "foos_foo" ADD CONSTRAINT
 "foos_foo_bar_id_efb062ad_fk_foos_bar_id"
 FOREIGN KEY ("bar_id")
 REFERENCES "bars_bar" ("id")
 DEFERRABLE INITIALLY DEFERRED;
 COMMIT;
 }}}

 I believe that we shouldn't be needing to re-create the FK constraint, so
 the following SQL should suffice:


 {{{
 BEGIN;
 --
 -- Alter field bar on foo
 --
 DROP INDEX IF EXISTS "foos_foo_bar_id_efb062ad";
 COMMIT;
 }}}

 Actually the main problem here is that dropping & adding constraints locks
 the entire table, and it might be catastrophic for some live production
 databases. IMHO this should either be documented or refactored. I look
 forward to hear your opinions on this, thank you in advance!

-- 
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/01070186eb3b4ff8-5df83534-8eac-4cf6-a822-16be56611ad6-00%40eu-central-1.amazonses.com.


Re: [Django] #33166: Add "field" to the context when rendering widgets.

2023-03-16 Thread Django
#33166: Add "field" to the context when rendering widgets.
-+-
 Reporter:  Jacob Rief   |Owner:  Jacob
 |  Rief
 Type:  New feature  |   Status:  assigned
Component:  Forms|  Version:  4.0
 Severity:  Normal   |   Resolution:
 Keywords:  form, widget,| Triage Stage:  Accepted
  context|
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * needs_better_patch:  0 => 1


Comment:

 Marking as "Patch needs improvement" as this is waiting for #34077.

-- 
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/01070186ea3546ec-e38fdea0-3e07-46a4-b7c4-7caa779a743f-00%40eu-central-1.amazonses.com.


Re: [Django] #22569: lookup_allowed fails to consider dynamic list_filter

2023-03-16 Thread Django
#22569: lookup_allowed fails to consider dynamic list_filter
-+-
 Reporter:  Keryn Knight |Owner:  (none)
   |
 Type:  Bug  |   Status:  new
Component:  contrib.admin|  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * cc: Sarah Boyce (added)


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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070186e9cd06c9-77869061-07e7-443b-8805-943c6cc6596f-00%40eu-central-1.amazonses.com.


Re: [Django] #28384: ModelAdmin.lookup_allowed() incorrectly raises DisallowedModelAdminLookup lookup with foreign key as primary key

2023-03-16 Thread Django
#28384: ModelAdmin.lookup_allowed() incorrectly raises 
DisallowedModelAdminLookup
lookup with foreign key as primary key
--+
 Reporter:  elliott-omosheye  |Owner:  nobody
 Type:  Bug   |   Status:  new
Component:  contrib.admin |  Version:  1.11
 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 Mariusz Felisiak):

 * cc: Sarah Boyce (added)


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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070186e9cbc4ef-132a7127-9724-4bc2-afc1-324d6e75e647-00%40eu-central-1.amazonses.com.


Re: [Django] #1873: Multi-select admin filter for RelatedFields

2023-03-16 Thread Django
#1873: Multi-select admin filter for RelatedFields
-+-
 Reporter:  marc@…   |Owner:  Sarah
 |  Boyce
 Type:  New feature  |   Status:  assigned
Component:  contrib.admin|  Version:
 Severity:  Normal   |   Resolution:
 Keywords:  nfa-changelist   | 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:"8d6f959be226edd9c0eb054a9babe9d4af399717" 8d6f959]:
 {{{
 #!CommitTicketReference repository=""
 revision="8d6f959be226edd9c0eb054a9babe9d4af399717"
 Refs #1873 -- Added test for IncorrectLookupParameters when list of values
 is passed to RelatedFieldListFilter.
 }}}

-- 
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/01070186e9b04af1-4ac9d81e-9213-4bcd-83bd-9db1f7326a09-00%40eu-central-1.amazonses.com.


Re: [Django] #1873: Multi-select admin filter for RelatedFields

2023-03-16 Thread Django
#1873: Multi-select admin filter for RelatedFields
-+-
 Reporter:  marc@…   |Owner:  Sarah
 |  Boyce
 Type:  New feature  |   Status:  assigned
Component:  contrib.admin|  Version:
 Severity:  Normal   |   Resolution:
 Keywords:  nfa-changelist   | 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:"d03dc63177ad3ba6e685e314eed45d6a8ec5cb0c" d03dc63]:
 {{{
 #!CommitTicketReference repository=""
 revision="d03dc63177ad3ba6e685e314eed45d6a8ec5cb0c"
 Refs #1873 -- Used GET.lists() in admin filters.
 }}}

-- 
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/01070186e9b04b15-ccb23e24-9692-40c1-89b0-fabe04b7c260-00%40eu-central-1.amazonses.com.


Re: [Django] #1873: Multi-select admin filter for RelatedFields

2023-03-16 Thread Django
#1873: Multi-select admin filter for RelatedFields
-+-
 Reporter:  marc@…   |Owner:  Sarah
 |  Boyce
 Type:  New feature  |   Status:  closed
Component:  contrib.admin|  Version:
 Severity:  Normal   |   Resolution:  fixed
 Keywords:  nfa-changelist   | 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:"d2b688b966f5d30414899549412d370e1317ddb8" d2b688b9]:
 {{{
 #!CommitTicketReference repository=""
 revision="d2b688b966f5d30414899549412d370e1317ddb8"
 Fixed #1873 -- Handled multi-valued query parameters in admin changelist
 filters.
 }}}

-- 
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/01070186e9b04b43-43606e4c-79ec-47b4-b0fe-34a20c00423d-00%40eu-central-1.amazonses.com.


Re: [Django] #34362: FilteredRelation doesn’t support conditional expression

2023-03-16 Thread Django
#34362: FilteredRelation doesn’t support conditional expression
-+-
 Reporter:  zhu  |Owner:  Francesco
 |  Panico
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  4.1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  1|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * needs_better_patch:  0 => 1
 * needs_tests:  0 => 1


-- 
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/01070186e99e028f-8789e310-fc7b-4461-af07-774916196f86-00%40eu-central-1.amazonses.com.


Re: [Django] #1873: Multi-select admin filter for RelatedFields

2023-03-16 Thread Django
#1873: Multi-select admin filter for RelatedFields
-+-
 Reporter:  marc@…   |Owner:  Sarah
 |  Boyce
 Type:  New feature  |   Status:  assigned
Component:  contrib.admin|  Version:
 Severity:  Normal   |   Resolution:
 Keywords:  nfa-changelist   | 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):

 * 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/01070186e959c2f0-70ff7a57-15ee-42e4-be52-37b83ffbf1dc-00%40eu-central-1.amazonses.com.


Re: [Django] #34404: Incorrect documentation about content type set by FileResponse object

2023-03-16 Thread Django
#34404: Incorrect documentation about content type set by FileResponse object
-+-
 Reporter:  chamalsl |Owner:  Ayush
 Type:   |  Bisht
  Cleanup/optimization   |   Status:  closed
Component:  Documentation|  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:  1|UI/UX:  0
-+-

Comment (by Mariusz Felisiak ):

 In [changeset:"eff2ba3f8d2f172c64b9df08db8d188e11bae855" eff2ba3f]:
 {{{
 #!CommitTicketReference repository=""
 revision="eff2ba3f8d2f172c64b9df08db8d188e11bae855"
 [4.2.x] Fixed #34404 -- Clarified how FileResponse set Content-Type
 header.

 Backport of fc266b694b9129e44b597d8a56927ee13fdac358 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/01070186e954e49a-55ba02e4-23a0-43de-b08c-af1b783bfc38-00%40eu-central-1.amazonses.com.


Re: [Django] #34404: Incorrect documentation about content type set by FileResponse object

2023-03-16 Thread Django
#34404: Incorrect documentation about content type set by FileResponse object
-+-
 Reporter:  chamalsl |Owner:  Ayush
 Type:   |  Bisht
  Cleanup/optimization   |   Status:  closed
Component:  Documentation|  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:  1|UI/UX:  0
-+-
Changes (by Mariusz Felisiak ):

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


Comment:

 In [changeset:"fc266b694b9129e44b597d8a56927ee13fdac358" fc266b69]:
 {{{
 #!CommitTicketReference repository=""
 revision="fc266b694b9129e44b597d8a56927ee13fdac358"
 Fixed #34404 -- Clarified how FileResponse set Content-Type header.
 }}}

-- 
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/01070186e954acc8-9551dcc0-3bf1-4410-9ae0-4995478b5cf0-00%40eu-central-1.amazonses.com.