diff --git a/README.md b/README.md index 975c1de5..4d5d891d 100644 --- a/README.md +++ b/README.md @@ -527,8 +527,6 @@ Data will only be downloaded/imported if it is newer than your data, and only ma The cities manage command has options, see `--help`. Verbosity is controlled through the `LOGGING` setting. - - ## Running Tests 1. Install postgres, postgis and libgdal-dev @@ -549,6 +547,23 @@ The cities manage command has options, see `--help`. Verbosity is controlled th # changes to github and specify commit and repo variables: TRAVIS_COMMIT=`git rev-parse HEAD` TRAVIS_REPO_SLUG='github-username/django-cities' POSTGRES_USER=some_username POSTGRES_PASSWORD='password from createuser ste' tox +## Running Django command + +If you need to run django comamnds, like ```makemigrations``` or ```makemessages``` (I guess the next step is +to make the software more compatible with other languages), you can do so easily, by configuring a few environment +variables **before** the actual command, like so: + +```bash +cd django-cities/ +POSTGRES_USER= POSTGRES_PASSWORD= PYTHONPATH=. python test_project/manage.py makemigrations cities +``` + +A few things should be noted: + +1. The ```cd``` command should point at the repository root; +1. The `````` and `````` are placeholders. That mean that you should substitute +them for the actual values of your database. + #### Useful test options: * `TRAVIS_LOG_LEVEL` - defaults to `INFO`, but set to `DEBUG` to see a (very) large and (very) complete log of the import script diff --git a/cities/migrations/0011_auto_20170126_1717.py b/cities/migrations/0011_auto_20170126_1717.py new file mode 100644 index 00000000..ad431fa6 --- /dev/null +++ b/cities/migrations/0011_auto_20170126_1717.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.5 on 2017-01-26 17:17 +from __future__ import unicode_literals + +import django.contrib.gis.db.models.fields +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('cities', '0010_adjust_unique_attributes'), + ] + + operations = [ + migrations.AddField( + model_name='city', + name='boundary', + field=django.contrib.gis.db.models.fields.MultiPolygonField(null=True, srid=4326), + ), + migrations.AddField( + model_name='continent', + name='boundary', + field=django.contrib.gis.db.models.fields.MultiPolygonField(null=True, srid=4326), + ), + migrations.AddField( + model_name='country', + name='boundary', + field=django.contrib.gis.db.models.fields.MultiPolygonField(null=True, srid=4326), + ), + migrations.AddField( + model_name='district', + name='boundary', + field=django.contrib.gis.db.models.fields.MultiPolygonField(null=True, srid=4326), + ), + migrations.AddField( + model_name='postalcode', + name='boundary', + field=django.contrib.gis.db.models.fields.MultiPolygonField(null=True, srid=4326), + ), + migrations.AddField( + model_name='region', + name='boundary', + field=django.contrib.gis.db.models.fields.MultiPolygonField(null=True, srid=4326), + ), + migrations.AddField( + model_name='subregion', + name='boundary', + field=django.contrib.gis.db.models.fields.MultiPolygonField(null=True, srid=4326), + ), + ] diff --git a/cities/models.py b/cities/models.py index 4d3c4fde..ed23f5bf 100644 --- a/cities/models.py +++ b/cities/models.py @@ -59,6 +59,8 @@ class Place(models.Model): name = models.CharField(max_length=200, db_index=True, verbose_name="ascii name") alt_names = models.ManyToManyField('AlternativeName') + boundary = models.MultiPolygonField(null=True) + objects = models.GeoManager() class Meta: @@ -86,6 +88,8 @@ def save(self, *args, **kwargs): class BaseContinent(Place, SlugModel): code = models.CharField(max_length=2, unique=True, db_index=True) + objects = models.GeoManager() + def __str__(self): return force_text(self.name) @@ -258,8 +262,6 @@ class AlternativeName(SlugModel): is_colloquial = models.BooleanField(default=False) is_historic = models.BooleanField(default=False) - objects = AlternativeNameManager() - def __str__(self): return "%s (%s)" % (force_text(self.name), force_text(self.language_code)) @@ -290,8 +292,6 @@ class PostalCode(Place, SlugModel): blank=True, null=True, related_name='postal_codes') district = models.ForeignKey(District, blank=True, null=True, related_name='postal_codes') - objects = models.GeoManager() - class Meta: unique_together = ( ('country', 'region', 'subregion', 'city', 'district', 'name', 'id', 'code'), diff --git a/test_project/test_app/settings.py b/test_project/test_app/settings.py index 0e926274..552a06a6 100644 --- a/test_project/test_app/settings.py +++ b/test_project/test_app/settings.py @@ -52,9 +52,9 @@ 'django.middleware.clickjacking.XFrameOptionsMiddleware', ) -ROOT_URLCONF = 'test_project.urls' +ROOT_URLCONF = 'test_app.urls' -WSGI_APPLICATION = 'test_project.wsgi.application' +WSGI_APPLICATION = 'test_app.wsgi.application' # Database