Python &引用;无效的几何图形值“;与geoadmin
我不能通过管理员添加信息,“无效几何值”总是出现 django==1.9.12 django Google地图==0.5 django传单==0.21.0 psycopg2==2.6.2 admin.py:Python &引用;无效的几何图形值“;与geoadmin,python,geodjango,Python,Geodjango,我不能通过管理员添加信息,“无效几何值”总是出现 django==1.9.12 django Google地图==0.5 django传单==0.21.0 psycopg2==2.6.2 admin.py: from django.contrib import admin from ascblog.models import Newspaper from leaflet.admin import LeafletGeoAdmin # Register your models here. clas
from django.contrib import admin
from ascblog.models import Newspaper
from leaflet.admin import LeafletGeoAdmin
# Register your models here.
class ascblogAdmin(LeafletGeoAdmin):
list_display=('date','archtype','structure','changnew','forman','content','location_name','location')
list_filter = ('date','archtype','structure','changnew','forman','content','location_name','location')
admin.site.register(Newspaper,ascblogAdmin)
models.py:
from django.db import models
from django.contrib.gis.db import models
class Newspaper(models.Model):
location = models.TextField(blank=True,max_length=5000)
location = models.PointField(srid=4326)
objects = models.GeoManager()
class Meta:
verbose_name_plural ="Newspaper"
settings.py:
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '*iqh-9kl3uo8813)4+u8+@&l_w&u43#_t*u2j2qya8hdmpqtgc'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
GEOS_LIBRARY_PATH ='C:/OSGeo4W64/bin/geos_c.dll'
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.gis',
'leaflet',
'ascblog',
]
MIDDLEWARE_CLASSES = [
'django.middleware.security.SecurityMiddleware',
#'django.middleware.locale.LocaleMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'archproject.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 = 'archproject.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.9/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME':'alldb',
'USER': 'postgres',
'PASSWORD': '0',
'HOST': '127.0.0.1',
'PORT': '4321',
}
}
# Password validation
# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
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',
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.9/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.9/howto/static-files/
STATIC_URL = '/static/'
LEAFLET_CONFIG={
'DEFAULT_CENTER':(24,121),
'DEFAULT_ZOOM':7,
'MAX_ZOOM':16,
'MIN_ZOOM':5,
'SCALE':'both',
'ATTRIBUTION_PREFIX':'HELLO I AM A STUDENT'
}
我有postgis和postgis_拓扑:add
python
tag来让你的问题被注意到……你在上面的代码中也有location
字段。对于我来说,django==1.10.6
和django传单==0.21.0
“@Udi”我使用1.10.6无法运行服务器错误消息:django.contrib.gis.db.backends.postgis'不是可用的数据库后端。尝试使用“django.db.backends.XXX”,其中XXX是“mysql”、“oracle”、“postgresql”和“sqlite”中的一个。错误是:无法导入名称“GdalMaster”。我使用1.9.12将正常,但必须添加代码GEOS_LIBRARY_PATH='C:/OSGeo4W64/bin/GEOS_C.dll'