Opened 3 weeks ago

Closed 3 weeks ago

Last modified 3 weeks ago

#36844 closed Cleanup/optimization (fixed)

Update packaging tutorial and AppConfig docs to mandate setting default_auto_field for reusable apps

Reported by: Jacob Walls Owned by: Amar
Component: Documentation Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

A reusable (third-party) app that:

  • has models
  • but does not set AppConfig.default_auto_field

is in a "completely broken" situation, given that any user attempting to use DEFAULT_AUTO_FIELD in their own settings will generate migrations for the reusable app, which can conflict with later migrations shipped by that app, or possibly get stored in the app's installation location:

Third-party apps should set default_auto_field so that the migrations the app includes match the models.

This discussion took place in a PR that was not accepted proposing to advise on user workarounds. Instead, I think we should advise app authors to do the right thing.

That would include:

  • strengthening the wording in AppConfig.default_auto_field docs, replacing "You can use this... for third party applications" to something like "Third-party applications *must* set this ..."
  • Fixing the tutorial to show this step under Packaging your app. To my knowledge (I'm hoping someone will confirm), when you follow the tutorial and arrive at this step modeling how to make your app reusable, there is no default_auto_field attribute on the AppConfig in apps.py.

This would be an approachable issue for a new contributor, as it involves following the tutorial to verify completeness and accuracy.

Change History (6)

comment:1 by Tim Graham, 3 weeks ago

Triage Stage: UnreviewedAccepted

comment:2 by Amar, 3 weeks ago

Owner: set to Amar
Status: newassigned

comment:3 by Amar, 3 weeks ago

Has patch: set

PR submitted: https://github.com/django/django/pull/20503

This patch:

  • Updates the AppConfig.default_auto_field documentation to clarify that reusable applications must set this attribute
  • Adds default_auto_field to the PollsConfig example in the packaging tutorial

This follows the guidance from the discussion in PR #20319.

comment:4 by Jacob Walls, 3 weeks ago

Triage Stage: AcceptedReady for checkin

comment:5 by Jacob Walls <jacobtylerwalls@…>, 3 weeks ago

Resolution: fixed
Status: assignedclosed

In 091ffc4e:

Fixed #36844 -- Clarified need for reusable apps to set default_auto_field in packaging tutorial and AppConfig docs.

comment:6 by Jacob Walls <jacobtylerwalls@…>, 3 weeks ago

In 8230e9b:

[6.0.x] Fixed #36844 -- Clarified need for reusable apps to set default_auto_field in packaging tutorial and AppConfig docs.

Backport of 091ffc4e5eb35776864b853973097588a36f169e from main.

Note: See TracTickets for help on using tickets.
Back to Top