@@ -14,7 +14,7 @@ Aurora DSQL Django adapter needs boto3 to work. Follow the Boto3 [installation g
1414
1515aurora_dsql_django requires Python 3.8 or later.
1616
17- Please see the link below for more detail to install Python:
17+ Please see the link below for more details to install Python:
1818
1919* [ Python Installation] ( https://www.python.org/downloads/ )
2020
@@ -34,7 +34,7 @@ First, install the adapter using pip:
3434### Define Aurora DSQL as the Engine for the Django App
3535
3636Change the `` DATABASES `` variable in `` settings.py `` of your Django app. An example
37- is show below
37+ is shown below:
3838
3939``` python
4040 DATABASES = {
@@ -47,9 +47,9 @@ is show below
4747 ' sslmode' : ' require' ,
4848 ' region' : ' us-east-2' ,
4949 # (optional) Defaults to 'default' profile if nothing is set
50- ' aws_profile' : ' user aws custom profile name'
50+ ' aws_profile' : ' user aws custom profile name' ,
5151 # (optional) Default is 900 seconds i.e., 15 mins
52- ' expires_in' : < token expiry time time in seconds>
52+ ' expires_in' : < token expiry time in seconds> ,
5353 # (optional) If sslmode is 'verify-full' then use sslrootcert
5454 # variable to set the path to server root certificate
5555 # If no path is provided, the adapter looks into system certs
@@ -66,7 +66,7 @@ For more info follow the [Aurora DSQL with Django example](examples/pet-clinic-a
6666
6767### Setup
6868
69- Assuming that you have Python installed, set up your environment and installed the dependencies
69+ Assuming that you have Python installed, set up your environment and install the dependencies
7070like this instead of the ` pip install aurora-dsql-django ` defined above:
7171
7272```
@@ -107,10 +107,129 @@ $ make html
107107
108108## Getting Help
109109
110- Please use these community resources for getting help.
110+ Please use these community resources for getting help:
111111* Open a support ticket with [ AWS Support] ( http://docs.aws.amazon.com/awssupport/latest/user/getting-started.html ) .
112112* If you think you may have found a bug, please open an [ issue] ( https://github.com/awslabs/aurora-dsql-django/issues/new ) .
113113
114+ ## Known Issues and Solutions
115+
116+ ### 1. When running migrations with the following Django Contrib Apps, you may encounter not-null constraint errors
117+ ```
118+ INSTALLED_APPS = [
119+ 'django.contrib.admin',
120+ 'django.contrib.auth',
121+ 'django.contrib.contenttypes',
122+ 'django.contrib.sessions']
123+ ```
124+
125+ Error Message:
126+
127+ ```
128+ django.db.utils.IntegrityError: null value in column "name" of relation "django_content_type" violates not-null constraint
129+ ```
130+
131+ #### Solution: Allow null values for the following columns
132+ - ``` 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)),
144+
145+ # To
146+ ("name", models.CharField(max_length=100, null=True)),
147+ ```
148+
149+ - ```last_login``` from the table ```auth_user```
150+
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+ ),
175+ ```
176+
177+
178+ ### 2. Null is used as the primary key during insertion for tables related to Django Contrib Apps
179+
180+ #### Solution: Ensure auto primary key generation is enabled
181+ - Add the attribute ```'ENABLE_ID_GENERATION_FOR_AUTO_FIELDS': True``` to DATABASES
182+ - Ensure the ```DEFAULT_AUTO_FIELD``` in ```settings.py``` is set to either ```django.db.models.BigAutoField``` or ```django.db.models.AutoField```
183+
184+ Note: This will automatically generate a default value for the AutoField and BigAutoField which can be used for the primary key.
185+
186+
187+ ```
188+ #settings.py
189+
190+ DATABASES = {
191+ 'default': {
192+ 'HOST': <HOST >,
193+ 'USER': <USER_NAME>,
194+ 'NAME': 'postgres',
195+ 'ENGINE': 'aurora_dsql_django',
196+ 'ENABLE_ID_GENERATION_FOR_AUTO_FIELDS': True,
197+ 'OPTIONS': {
198+ 'sslmode': 'verify-full',
199+ 'region': 'us-east-1'
200+ }
201+ }
202+ }
203+
204+
205+ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
206+ ```
207+
208+
209+ ### 3. DeclareCursor is not supported
210+
211+ #### Solution: Disable Server Side Cursors
212+ - Add the attribute ```'DISABLE_SERVER_SIDE_CURSORS': True``` to DATABASES in ```settings.py```. Note: ```DISABLE_SERVER_SIDE_CURSORS``` should be at the same level as ```OPTIONS```, not within it
213+ ```
214+ #settings.py
215+
216+ DATABASES = {
217+ 'default': {
218+ 'HOST': <HOST >,
219+ 'USER': <USER_NAME>,
220+ 'NAME': 'postgres',
221+ 'ENGINE': 'aurora_dsql_django',
222+ 'DISABLE_SERVER_SIDE_CURSORS': True, # Fixes unsupported statement: DeclareCursor
223+ 'OPTIONS': {
224+ 'sslmode': 'verify-full',
225+ 'region': 'us-east-1'
226+ }
227+ }
228+ }
229+ ```
230+
231+
232+
114233## Opening Issues
115234
116235If you encounter a bug with the Aurora DSQL Django adapter, we would like to hear about it. Please search the [existing issues](https://github.com/awslabs/aurora-dsql-django/issues) and see if others are also experiencing the issue before opening a new issue. When opening a new issue please follow the template.
0 commit comments