Skip to content

Commit d30bc59

Browse files
author
Victor Tsang
committed
updated README
1 parent 2afb80e commit d30bc59

File tree

1 file changed

+10
-37
lines changed

1 file changed

+10
-37
lines changed

README.md

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -130,49 +130,22 @@ django.db.utils.IntegrityError: null value in column "name" of relation "django_
130130

131131
#### Solution: Allow null values for the following columns
132132
- ```name``` from the table ```django_content_type```
133-
- Locate the installed django library in the site-packages folder (within the venv folder)
134-
- Navigate to
135-
```
136-
venv/lib/python3.13/site-packages/django/contrib/contenttypes/migrations/0001_initial.py
137-
```
138-
- Modify the ```name``` field by adding ```null=True``` under ```migrations.CreateModel(name="ContentType")``` and save your change
139-
```
140-
#0001_initial.py
141-
142-
# From
143-
("name", models.CharField(max_length=100)),
133+
- connect to your DSQL cluster via ```psql```
134+
- execute the following queries:
135+
``` sql
136+
DROP TABLE IF EXISTS "django_content_type";
144137

145-
# To
146-
("name", models.CharField(max_length=100, null=True)),
138+
CREATE TABLE "django_content_type" ("id" integer NOT NULL PRIMARY KEY, "name" varchar(100), "app_label" varchar(100) NOT NULL, "model" varchar(100) NOT NULL);
147139
```
148140

149141
- ```last_login``` from the table ```auth_user```
142+
- execute the following queries:
143+
``` sql
144+
DROP TABLE IF EXISTS "auth_user";
150145
151-
- Navigate to
152-
```
153-
venv/lib/python3.13/site-packages/django/contrib/auth/migrations/0001_initial.py
154-
```
155-
- Modify the ```last_login``` field by adding ```null=True``` under ```migrations.CreateModel(name="User")``` and save your change
156-
157-
```
158-
# 0001_initial.py
159-
160-
# From
161-
(
162-
"last_login",
163-
models.DateTimeField(
164-
default=timezone.now, verbose_name="last login"
165-
),
166-
),
167-
168-
# To
169-
(
170-
"last_login",
171-
models.DateTimeField(
172-
default=timezone.now, verbose_name="last login", null=True
173-
),
174-
),
146+
CREATE TABLE "auth_user" ("id" integer NOT NULL PRIMARY KEY, "password" varchar(128) NOT NULL, "last_login" timestamptz, "is_superuser" boolean NOT NULL, "username" varchar(150) NOT NULL UNIQUE, "first_name" varchar(150) NOT NULL, "last_name" varchar(150) NOT NULL, "email" varchar(254) NOT NULL, "is_staff" boolean NOT NULL, "is_active" boolean NOT NULL, "date_joined" timestamptz NOT NULL);
175147
```
148+
- Run ```python manage.py migrate``` again. The errors should be resolved.
176149

177150

178151
### 2. Null is used as the primary key during insertion for tables related to Django Contrib Apps

0 commit comments

Comments
 (0)