Skip to content

Conversation

@scollazo
Copy link
Member

Removes models.W042 warning when running manage.py commands

Connected to archivematica/Issues#1759

@scollazo scollazo force-pushed the dev/issue-1759-w042-warning branch from a41a5f6 to a33d937 Compare August 20, 2025 09:37
@scollazo scollazo requested a review from replaceafill August 20, 2025 12:38
LOGIN_EXEMPT_URLS.append(r"^metrics$")

# Remove models.W042 warning
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removes models.W042 warning when running manage.py commands
This removes the warnings about autocreated primary keys
@scollazo scollazo force-pushed the dev/issue-1759-w042-warning branch from a33d937 to 8909bc5 Compare September 16, 2025 08:30
@scollazo
Copy link
Member Author

@replaceafill , I removed the defalt_auto_field and used systemd_silence_checks only for production. Does this look better?

@scollazo scollazo changed the title Set DEFAULT_AUTO_FIELD Remove warnings about autocreated index fields Sep 16, 2025
@replaceafill
Copy link
Member

replaceafill commented Sep 16, 2025

@scollazo I think instead of hardcoding the setting value we should expose the SILENCED_SYSTEM_CHECKS Django setting the same way expose other Django settings: with application variables in the Dashboard and application-specific environment variables in the Storage Service. That way we could document their default values and explain where those codes (i.e. models.W042) come from and allow users to customize them.

@scollazo
Copy link
Member Author

Done!

@scollazo scollazo force-pushed the dev/issue-1759-w042-warning branch from de37cbb to fad99d6 Compare September 18, 2025 15:09
- **Type:** `integer`
- **Default:** `900`

- **`SS_SILENCED_SYSTEM_CHECKS`**:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of dropping SS_ prefix? We are not really consistent but most of the Django related variables don't have it. Also could we move this documentation bit after the SECRET_KEY variable?

Comment on lines +227 to +228
- **Description:** comma-separated list of ignored system checks.
e.g. mysql.W002,models.W042
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a link to https://docs.djangoproject.com/en/4.2/ref/settings/#silenced-system-checks here. See examples in TIME_ZONE or SECRET_KEY above.

INSTALLED_APPS = INSTALLED_APPS + ["django_prometheus"]
LOGIN_EXEMPT_URLS.append(r"^metrics$")

SILENCED_SYSTEM_CHECKS = environ.get("SS_SILENCED_SYSTEM_CHECKS", "[]")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're expecting the user to set a comma separated list it needs to be converted to a list here:

Suggested change
SILENCED_SYSTEM_CHECKS = environ.get("SS_SILENCED_SYSTEM_CHECKS", "[]")
SILENCED_SYSTEM_CHECKS = environ.get("SS_SILENCED_SYSTEM_CHECKS", "").split(",")

- **Description:** comma-separated list of ignored system checks.
e.g. mysql.W002,models.W042
- **Type:** `string`
- **Default:** `None`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- **Default:** `None`
- **Default:** `""`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants