Skip to content

Commit 4e7e1f7

Browse files
authored
Docs: update bullet/item list display (#11123)
It seems the rendering was broken, had a ` - #.` when it should be only `#.`. This PR should fix the rendering.
1 parent f283500 commit 4e7e1f7

File tree

1 file changed

+58
-58
lines changed

1 file changed

+58
-58
lines changed

docs/dev/migrations.rst

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -15,66 +15,66 @@ This way, the database can be migrated without downtime, and the field can be po
1515
Don't forget to make the field non-nullable in a separate migration after the data has been populated.
1616
You can achieve this by following these steps:
1717

18-
- #. Set the new field as ``null=True`` and ``blank=True`` in the model.
18+
#. Set the new field as ``null=True`` and ``blank=True`` in the model.
1919

20-
.. code-block:: python
20+
.. code-block:: python
2121
22-
class MyModel(models.Model):
23-
new_field = models.CharField(
24-
max_length=100, null=True, blank=True, default="default"
25-
)
22+
class MyModel(models.Model):
23+
new_field = models.CharField(
24+
max_length=100, null=True, blank=True, default="default"
25+
)
2626
27-
- #. Make sure that the field is always populated with a proper value in the new code,
28-
and the code handles the case where the field is null.
27+
#. Make sure that the field is always populated with a proper value in the new code,
28+
and the code handles the case where the field is null.
2929

30-
.. code-block:: python
30+
.. code-block:: python
3131
32-
if my_model.new_field in [None, "default"]:
33-
pass
32+
if my_model.new_field in [None, "default"]:
33+
pass
3434
3535
36-
# If it's a boolean field, make sure that the null option is removed from the form.
37-
class MyModelForm(forms.ModelForm):
38-
def __init__(self, *args, **kwargs):
39-
super().__init__(*args, **kwargs)
40-
self.fields["new_field"].widget = forms.CheckboxInput()
41-
self.fields["new_field"].empty_value = False
36+
# If it's a boolean field, make sure that the null option is removed from the form.
37+
class MyModelForm(forms.ModelForm):
38+
def __init__(self, *args, **kwargs):
39+
super().__init__(*args, **kwargs)
40+
self.fields["new_field"].widget = forms.CheckboxInput()
41+
self.fields["new_field"].empty_value = False
4242
43-
- #. Create the migration file (let's call this migration ``app 0001``),
44-
and mark it as ``Safe.before_deploy``.
43+
#. Create the migration file (let's call this migration ``app 0001``),
44+
and mark it as ``Safe.before_deploy``.
4545

46-
.. code-block:: python
46+
.. code-block:: python
4747
48-
from django.db import migrations, models
49-
from django_safemigrate import Safe
48+
from django.db import migrations, models
49+
from django_safemigrate import Safe
5050
5151
52-
class Migration(migrations.Migration):
53-
safe = Safe.before_deploy
52+
class Migration(migrations.Migration):
53+
safe = Safe.before_deploy
5454
55-
- #. Create a data migration to populate all null values of the new field with a proper value (let's call this migration ``app 0002``),
56-
and mark it as ``Safe.after_deploy``.
55+
#. Create a data migration to populate all null values of the new field with a proper value (let's call this migration ``app 0002``),
56+
and mark it as ``Safe.after_deploy``.
5757

58-
.. code-block:: python
58+
.. code-block:: python
5959
60-
from django.db import migrations
60+
from django.db import migrations
6161
6262
63-
def migrate(apps, schema_editor):
64-
MyModel = apps.get_model("app", "MyModel")
65-
MyModel.objects.filter(new_field=None).update(new_field="default")
63+
def migrate(apps, schema_editor):
64+
MyModel = apps.get_model("app", "MyModel")
65+
MyModel.objects.filter(new_field=None).update(new_field="default")
6666
6767
68-
class Migration(migrations.Migration):
69-
safe = Safe.after_deploy
68+
class Migration(migrations.Migration):
69+
safe = Safe.after_deploy
7070
71-
operations = [
72-
migrations.RunPython(migrate),
73-
]
71+
operations = [
72+
migrations.RunPython(migrate),
73+
]
7474
75-
- #. After the deploy has been completed, create a new migration to set the field as non-nullable (let's call this migration ``app 0003``).
76-
Run this migration on a new deploy, you can mark it as ``Safe.before_deploy`` or ``Safe.always``.
77-
- #. Remove any handling of the null case from the code.
75+
#. After the deploy has been completed, create a new migration to set the field as non-nullable (let's call this migration ``app 0003``).
76+
Run this migration on a new deploy, you can mark it as ``Safe.before_deploy`` or ``Safe.always``.
77+
#. Remove any handling of the null case from the code.
7878

7979
At the end, the deploy should look like this:
8080

@@ -93,37 +93,37 @@ all usages of the field should be removed from the code before the field is remo
9393
and the field should be nullable.**
9494
You can achieve this by following these steps:
9595

96-
- #. Remove all usages of the field from the code.
97-
- #. Set the field as ``null=True`` and ``blank=True`` in the model.
96+
#. Remove all usages of the field from the code.
97+
#. Set the field as ``null=True`` and ``blank=True`` in the model.
9898

99-
.. code-block:: python
99+
.. code-block:: python
100100
101-
class MyModel(models.Model):
102-
field_to_delete = models.CharField(max_length=100, null=True, blank=True)
101+
class MyModel(models.Model):
102+
field_to_delete = models.CharField(max_length=100, null=True, blank=True)
103103
104-
- #. Create the migration file (let's call this migration ``app 0001``),
105-
and mark it as ``Safe.before_deploy``.
104+
#. Create the migration file (let's call this migration ``app 0001``),
105+
and mark it as ``Safe.before_deploy``.
106106

107-
.. code-block:: python
107+
.. code-block:: python
108108
109-
from django.db import migrations, models
110-
from django_safemigrate import Safe
109+
from django.db import migrations, models
110+
from django_safemigrate import Safe
111111
112112
113-
class Migration(migrations.Migration):
114-
safe = Safe.before_deploy
113+
class Migration(migrations.Migration):
114+
safe = Safe.before_deploy
115115
116-
- #. Create a migration to remove the field from the database (let's call this migration ``app 0002``),
117-
and mark it as ``Safe.after_deploy``.
116+
#. Create a migration to remove the field from the database (let's call this migration ``app 0002``),
117+
and mark it as ``Safe.after_deploy``.
118118

119-
.. code-block:: python
119+
.. code-block:: python
120120
121-
from django.db import migrations, models
122-
from django_safemigrate import Safe
121+
from django.db import migrations, models
122+
from django_safemigrate import Safe
123123
124124
125-
class Migration(migrations.Migration):
126-
safe = Safe.after_deploy
125+
class Migration(migrations.Migration):
126+
safe = Safe.after_deploy
127127
128128
At the end, the deploy should look like this:
129129

0 commit comments

Comments
 (0)