when i made manage.py migrations i went sucessfully but when i run manage.py migrate
i am new to geodjango pls help me
import os
if os.name=='nt':
import platform
OSGEO4W=r"C:\OSGeo4w"
if '64' in platform.architecture()[0]:
OSGEO4W+="64"
assert os.path.isdir(OSGEO4W), "Directory does not exist:"+OSGEO4W
os.environ['OSGEO4W_ROOT']=OSGEO4W
os.environ['GDAL_DATA']=OSGEO4W+r"\share\gdal"
os.environ['PROJ_LIB']=OSGEO4W+r"\share\proj"
os.environ['PATH']=OSGEO4W+r"\bin;"+os.environ['PATH']
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = '+2r35-w0_kqcr4ygbt474-!xx9q9izus$-+)g)%(-+=8d*^1pt'
DEBUG = False
ALLOWED_HOSTS = []
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.gis',
'leaflet',
'repoter',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'agricon.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'agricon.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME': 'postgis_25_sample',
'USER': 'postgres',
'PASSWORD': 'Shanmukhavarma99@',
'HOST': 'localhost',
'PORT': '5432',
}
}
GEOS_LIBRARY_PATH = r'C:\\OSGeo4W\\bin\\geos_c.dll'
GDAL_LIBRARY_PATH = r'C:\OSGeo4W\\bin\\gdal204.dll'
AUTH_PASSWORD_VALIDATORS = [
{
'NAME':
'django.contrib.auth.password_validation.
UserAttributeSimilarityValidator',
},
{
'NAME':
'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME':
'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME':
'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATIC_URL = '/static/'
LEAFLET_CONFIG={
'DEFAULT_ZOOM':1,
'MAX_ZOOM':30,
'MIN_ZOOM':10,
'SCALE':'both',
}
from django.db import models
from django.contrib.gis.db import models
class incides(models.Model):
name=models.CharField(max_length=100)
location=models.PointField(srid=4326)
def __str__(self):
return self.name
class Meta:
verbose_name_plural='incides'
class welcome(models.Model):
fips = models.CharField(max_length=20)
iso2 = models.CharField(max_length=20)
iso3 = models.CharField(max_length=3)
un = models.IntegerField()
name = models.CharField(max_length=50)
area = models.IntegerField()
pop2005 = models.BigIntegerField()
region = models.IntegerField()
subregion = models.IntegerField()
lon = models.FloatField()
lat = models.FloatField()
geom = models.MultiPolygonField(srid=4326)
def __str__(self):
return 'Name: %s' % self.fips
import os
from django.contrib.gis.utils import LayerMapping
from .models import welcome
welcome_mapping = {
'fips': 'FIPS',
'iso2': 'ISO2',
'iso3': 'ISO3',
'un': 'UN',
'name': 'NAME',
'area': 'AREA',
'pop2005': 'POP2005',
'region': 'REGION',
'subregion': 'SUBREGION',
'lon': 'LON',
'lat': 'LAT',
'geom': 'MULTIPOLYGON',
}
welcome_shp=os.path.abspath(os.path.join(os.path.dirname("C:\\Users\\hp
\\Desktop\\googlemaps\\agricon\\repoter\\data"), 'data',
'TM_WORLD_BORDERS-0.3.shp'),)
def run(verbose=True):
ln=LayerMapping(welcome,welcome_shp,welcome_mapping,
transform=False,encoding='iso-8859-1')
ln.save(strict=True,verbose=verbose)
C:\Users\hp\Desktop\googlemaps\agricon>python manage.py makemigrations
No changes detected
C:\Users\hp\Desktop\googlemaps\agricon>python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, repoter, sessions
Running migrations:
Applying repoter.0002_auto_20190825_1454...Traceback (most recent call
last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "C:\Users\hp\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\django\core\management\__init__.py", line 381, in
execute_from_command_line
utility.execute()
File "C:\Users\hp\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\django\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\hp\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\django\core\management\base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\hp\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\django\core\management\base.py", line 364, in execute
output = self.handle(*args, **options)
File "C:\Users\hp\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\django\core\management\base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "C:\Users\hp\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\django\core\management\commands\migrate.py", line 234, in handle
fake_initial=fake_initial,
File "C:\Users\hp\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\django\db\migrations\executor.py", line 117, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake,
fake_initial=fake_initial)
File "C:\Users\hp\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\django\db\migrations\executor.py", line 147, in
_migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake,
fake_initial=fake_initial)
File "C:\Users\hp\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\django\db\migrations\executor.py", line 245, in apply_migration
state = migration.apply(state, schema_editor)
File "C:\Users\hp\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\django\db\migrations\migration.py", line 124, in apply
operation.database_forwards(self.app_label, schema_editor, old_state,
project_state)
File "C:\Users\hp\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\django\db\migrations\operations\fields.py", line 112, in
database_forwards
field,
File "C:\Users\hp\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\django\db\backends\base\schema.py", line 433, in add_field
definition, params = self.column_sql(model, field, include_default=True)
File "C:\Users\hp\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\django\db\backends\base\schema.py", line 161, in column_sql
default_value = self.effective_default(field)
File "C:\Users\hp\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\django\db\backends\base\schema.py", line 233, in
effective_default
return field.get_db_prep_save(self._effective_default(field),
self.connection)
File "C:\Users\hp\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\django\db\models\fields\__init__.py", line 789, in
get_db_prep_save
return self.get_db_prep_value(value, connection=connection,
prepared=False)
File "C:\Users\hp\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\django\contrib\gis\db\models\fields.py", line 147, in
get_db_prep_value
super().get_db_prep_value(value, connection, *args, **kwargs),
File "C:\Users\hp\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\django\db\models\fields\__init__.py", line 784, in
get_db_prep_value
value = self.get_prep_value(value)
File "C:\Users\hp\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\django\contrib\gis\db\models\fields.py", line 186, in
get_prep_value
obj = GEOSGeometry(obj)
File "C:\Users\hp\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\django\contrib\gis\geos\geometry.py", line 715, in __init__
raise ValueError('String input unrecognized as WKT EWKT, and HEXEWKB.')
ValueError: String input unrecognized as WKT EWKT, and HEXEWKB.
i have deleted all the migrations that i have created and again created new migration then it worked and got output