Skip to content

Upgrade to Django 5.x #12104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Apr 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion common
18 changes: 9 additions & 9 deletions docs/dev/migrations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ You can achieve this by following these steps:
self.fields["new_field"].empty_value = False

#. Create the migration file (let's call this migration ``app 0001``),
and mark it as ``Safe.before_deploy``.
and mark it as ``Safe.before_deploy()``.

.. code-block:: python

Expand All @@ -50,10 +50,10 @@ You can achieve this by following these steps:


class Migration(migrations.Migration):
safe = Safe.before_deploy
safe = Safe.before_deploy()

#. Create a data migration to populate all null values of the new field with a proper value (let's call this migration ``app 0002``),
and mark it as ``Safe.after_deploy``.
and mark it as ``Safe.after_deploy()``.

.. code-block:: python

Expand All @@ -66,14 +66,14 @@ You can achieve this by following these steps:


class Migration(migrations.Migration):
safe = Safe.after_deploy
safe = Safe.after_deploy()

operations = [
migrations.RunPython(migrate),
]

#. After the deploy has been completed, create a new migration to set the field as non-nullable (let's call this migration ``app 0003``).
Run this migration on a new deploy, you can mark it as ``Safe.before_deploy`` or ``Safe.always``.
Run this migration on a new deploy, you can mark it as ``Safe.before_deploy()`` or ``Safe.always()``.
#. Remove any handling of the null case from the code.

At the end, the deploy should look like this:
Expand Down Expand Up @@ -102,7 +102,7 @@ You can achieve this by following these steps:
field_to_delete = models.CharField(max_length=100, null=True, blank=True)

#. Create the migration file (let's call this migration ``app 0001``),
and mark it as ``Safe.before_deploy``.
and mark it as ``Safe.before_deploy()``.

.. code-block:: python

Expand All @@ -111,10 +111,10 @@ You can achieve this by following these steps:


class Migration(migrations.Migration):
safe = Safe.before_deploy
safe = Safe.before_deploy()

#. Create a migration to remove the field from the database (let's call this migration ``app 0002``),
and mark it as ``Safe.after_deploy``.
and mark it as ``Safe.after_deploy()``.

.. code-block:: python

Expand All @@ -123,7 +123,7 @@ You can achieve this by following these steps:


class Migration(migrations.Migration):
safe = Safe.after_deploy
safe = Safe.after_deploy()

At the end, the deploy should look like this:

Expand Down
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ filterwarnings =
ignore:DateTimeField .* received a naive datetime .* while time zone support is active:RuntimeWarning
ignore:.*:DeprecationWarning

ignore:.*:django.utils.deprecation.RemovedInDjango50Warning
ignore:.*:django.utils.deprecation.RemovedInDjango60Warning
ignore:.*:elasticsearch.exceptions.ElasticsearchWarning
ignore:.*:PendingDeprecationWarning
2 changes: 1 addition & 1 deletion readthedocs/analytics/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


class Migration(migrations.Migration):
safe = Safe.after_deploy
safe = Safe.after_deploy()
initial = True

dependencies = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class Migration(migrations.Migration):
safe = Safe.after_deploy
safe = Safe.after_deploy()
dependencies = [
("builds", "0041_track_task_id"),
("projects", "0087_use_booleanfield_null"),
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/analytics/migrations/0003_remove_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


class Migration(migrations.Migration):
safe = Safe.after_deploy
safe = Safe.after_deploy()
dependencies = [
("analytics", "0002_track_status_code"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def forwards_func(apps, schema_editor):


class Migration(migrations.Migration):
safe = Safe.after_deploy
safe = Safe.after_deploy()
dependencies = [
("analytics", "0003_remove_index"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


class Migration(migrations.Migration):
safe = Safe.after_deploy
safe = Safe.after_deploy()
dependencies = [
("analytics", "0004_merge_duplicate_records"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


class Migration(migrations.Migration):
safe = Safe.after_deploy
safe = Safe.after_deploy()
dependencies = [
("analytics", "0005_add_unique_constraint"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


class Migration(migrations.Migration):
safe = Safe.after_deploy
safe = Safe.after_deploy()
dependencies = [
("analytics", "0006_alter_pageview_id"),
]
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/api/v2/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class Migration(migrations.Migration):
safe = Safe.after_deploy
safe = Safe.after_deploy()
initial = True

dependencies = [
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/audit/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


class Migration(migrations.Migration):
safe = Safe.after_deploy
safe = Safe.after_deploy()
initial = True

dependencies = [
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/audit/migrations/0002_add_organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


class Migration(migrations.Migration):
safe = Safe.after_deploy
safe = Safe.after_deploy()
dependencies = [
("organizations", "0006_add_assets_cleaned"),
("audit", "0001_initial"),
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/audit/migrations/0003_update_ordering.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


class Migration(migrations.Migration):
safe = Safe.after_deploy
safe = Safe.after_deploy()
dependencies = [
("audit", "0002_add_organization"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


class Migration(migrations.Migration):
safe = Safe.after_deploy
safe = Safe.after_deploy()
dependencies = [
("audit", "0003_update_ordering"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def forwards_func(apps, schema_editor):


class Migration(migrations.Migration):
safe = Safe.after_deploy
safe = Safe.after_deploy()
dependencies = [
("audit", "0004_change_ip_field_type"),
]
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/audit/migrations/0006_add_download_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


class Migration(migrations.Migration):
safe = Safe.after_deploy
safe = Safe.after_deploy()
dependencies = [
("audit", "0005_migrate_ip_field_values"),
]
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/audit/migrations/0007_auditlog_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


class Migration(migrations.Migration):
safe = Safe.after_deploy
safe = Safe.after_deploy()
dependencies = [
("audit", "0006_add_download_action"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


class Migration(migrations.Migration):
safe = Safe.after_deploy
safe = Safe.after_deploy()
dependencies = [
("audit", "0007_auditlog_data"),
]
Expand Down
6 changes: 1 addition & 5 deletions readthedocs/builds/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


class Migration(migrations.Migration):
safe = Safe.always
safe = Safe.always()
dependencies = [
("projects", "0001_initial"),
("taggit", "0001_initial"),
Expand Down Expand Up @@ -247,8 +247,4 @@ class Migration(migrations.Migration):
name="version",
unique_together={("project", "slug")},
),
migrations.AlterIndexTogether(
name="build",
index_together={("version", "state", "type")},
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class Migration(migrations.Migration):
safe = Safe.after_deploy
safe = Safe.after_deploy()
dependencies = [
("builds", "0001_initial"),
]
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/builds/migrations/0003_add-cold-storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


class Migration(migrations.Migration):
safe = Safe.after_deploy
safe = Safe.after_deploy()
dependencies = [
("builds", "0002_build_command_initial"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


class Migration(migrations.Migration):
safe = Safe.after_deploy
safe = Safe.after_deploy()
dependencies = [
("builds", "0003_add-cold-storage"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


class Migration(migrations.Migration):
safe = Safe.always
safe = Safe.always()
dependencies = [
("builds", "0004_add-apiversion-proxy-model"),
]
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/builds/migrations/0006_add_config_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


class Migration(migrations.Migration):
safe = Safe.after_deploy
safe = Safe.after_deploy()
dependencies = [
("builds", "0005_remove-version-alias"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


class Migration(migrations.Migration):
safe = Safe.after_deploy
safe = Safe.after_deploy()
dependencies = [
("projects", "0042_increase_env_variable_value_max_length"),
("contenttypes", "0002_remove_content_type_name"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


class Migration(migrations.Migration):
safe = Safe.after_deploy
safe = Safe.after_deploy()
dependencies = [
("builds", "0007_add-automation-rules"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


class Migration(migrations.Migration):
safe = Safe.after_deploy
safe = Safe.after_deploy()
dependencies = [
("builds", "0008_remove-version-tags"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


class Migration(migrations.Migration):
safe = Safe.after_deploy
safe = Safe.after_deploy()
dependencies = [
("builds", "0009_added_external_version_type"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


class Migration(migrations.Migration):
safe = Safe.after_deploy
safe = Safe.after_deploy()
dependencies = [
("builds", "0010_add-description-field-to-automation-rule"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


class Migration(migrations.Migration):
safe = Safe.after_deploy
safe = Safe.after_deploy()
dependencies = [
("builds", "0011_version-media-availability"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


class Migration(migrations.Migration):
safe = Safe.after_deploy
safe = Safe.after_deploy()
dependencies = [
("builds", "0012_add-predefined-match-arg-field"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def forwards_func(apps, schema_editor):


class Migration(migrations.Migration):
safe = Safe.after_deploy
safe = Safe.after_deploy()
dependencies = [
("builds", "0013_version_documentation_type"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


class Migration(migrations.Migration):
safe = Safe.after_deploy
safe = Safe.after_deploy()
dependencies = [
("builds", "0014_migrate-doctype-from-project-to-version"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


class Migration(migrations.Migration):
safe = Safe.after_deploy
safe = Safe.after_deploy()
dependencies = [
("builds", "0015_uploading_build_state"),
]
Expand Down
Loading