From 28ac65332cf7177c00e14294cdd883f71d2a6930 Mon Sep 17 00:00:00 2001 From: Egor fureunoir Gorbunov Date: Mon, 19 May 2025 17:18:00 +0300 Subject: [PATCH] Features: 1) Add new fields (city, region, postal_code, country, location, raw_data, api_response, user) to the Address model via migration 0004; 2) Introduce user ForeignKey to link Address model with AUTH_USER_MODEL. Fixes: 1) Correct PointField import in migration 0001 to resolve GIS model inconsistency. Extra: Adjust formatting in migration files for consistency. --- geo/migrations/0001_initial.py | 6 +-- geo/migrations/0004_add_missing_fields.py | 57 +++++++++++++++++++++++ 2 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 geo/migrations/0004_add_missing_fields.py diff --git a/geo/migrations/0001_initial.py b/geo/migrations/0001_initial.py index 99a61758..3d92bea5 100644 --- a/geo/migrations/0001_initial.py +++ b/geo/migrations/0001_initial.py @@ -38,9 +38,9 @@ class Migration(migrations.Migration): ('region', models.CharField(max_length=100, null=True, verbose_name='region')), ('postal_code', models.CharField(max_length=20, null=True, verbose_name='postal code')), ('country', models.CharField(max_length=40, null=True, verbose_name='country')), - ('location', django.contrib.gis.db.models.fields.PointField(blank=True, geography=True, - help_text='Geolocation point: (longitude, latitude)', - null=True, srid=4326)), + ('location', django.contrib.gis.db.models.PointField(blank=True, geography=True, + help_text='Geolocation point: (longitude, latitude)', + null=True, srid=4326)), ('raw_data', models.JSONField(blank=True, help_text='Full JSON response from geocoder for this address', null=True)), ('api_response', diff --git a/geo/migrations/0004_add_missing_fields.py b/geo/migrations/0004_add_missing_fields.py new file mode 100644 index 00000000..17cf9f25 --- /dev/null +++ b/geo/migrations/0004_add_missing_fields.py @@ -0,0 +1,57 @@ +import django.contrib.gis.db.models.fields +from django.conf import settings + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ('geo', '0003_add_district_field'), + ] + + operations = [ + migrations.AddField( + model_name='address', + name='city', + field=models.CharField(max_length=255, null=True, verbose_name='city'), + ), + migrations.AddField( + model_name='address', + name='region', + field=models.CharField(max_length=255, null=True, verbose_name='region'), + ), + migrations.AddField( + model_name='address', + name='postal_code', + field=models.CharField(max_length=255, null=True, verbose_name='postal_code'), + ), + migrations.AddField( + model_name='address', + name='country', + field=models.CharField(max_length=255, null=True, verbose_name='country'), + ), + migrations.AddField( + model_name='address', + name='location', + field=django.contrib.gis.db.models.PointField(blank=True, geography=True, + help_text='Geolocation point: (longitude, latitude)', + null=True, srid=4326), + ), + migrations.AddField( + model_name='address', + name='raw_data', + field=models.JSONField(blank=True, help_text='Full JSON response from geocoder for this address', + null=True), + ), + migrations.AddField( + model_name='address', + name='api_response', + field=models.JSONField(blank=True, help_text='Stored JSON response from the geocoding service', null=True), + ), + migrations.AddField( + model_name='address', + name='user', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, + to=settings.AUTH_USER_MODEL), + ), + ]