erdem / django-map-widgets

Highly customizable, intuitive, and user-friendly map widgets for GeoDjango applications.
MIT License
450 stars 119 forks source link

map image not found #110

Closed Sarthak77tiwari closed 4 years ago

Sarthak77tiwari commented 4 years ago

my project map image not found i have run python manage.py collectstatic my settings.py ` import os

if os.name == 'nt': import platform

POSTGRES = r"C:\Program Files\PostgreSQL\10"
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['POSTGRES_ROOT'] = POSTGRES
os.environ['GDAL_LIBRARY_PATH'] = OSGEO4W + r"\bin"
os.environ['GEOS_LIBRARY_PATH'] = OSGEO4W + r"\bin"
os.environ['GDAL_DATA'] = OSGEO4W + r"\share\gdal"
os.environ['PROJ_LIB'] = OSGEO4W + r"\share\proj"
os.environ['PATH'] = OSGEO4W + r"\bin;" + POSTGRES + r"\bin;" + os.environ['PATH']

`BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(file)))

SECRET_KEY = '*judq@g52ok2&b2(u6ibif$=s^#z=%kjembjkes2dini2x_0w$' GOOGLE_MAP_API_KEY = 'AIzaSyAsFJ2MtCH2UXxTNPQAKvH_GdyRYqW3U1k' MAP_WIDGETS = { "GooglePointFieldWidget": ( ("zoom", 15), ("mapCenterLocationName", "london"), ), "GOOGLE_MAP_API_KEY": "" }

DEBUG = True

ALLOWED_HOSTS = []`

`INSTALLED_APPS = [

'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'mapwidgets',
'django.contrib.gis',
'shiv.apps.ShivConfig',

]`

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 = 'llife.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 = 'llife.wsgi.application'

DATABASES = { 'default': { 'ENGINE': 'django.contrib.gis.db.backends.postgis', 'NAME': 'geodjangodb', 'USER': 'geo_admin', 'PASSWORD': 'geoadmin', 'HOST': 'localhost', 'PORT': '5432', } }

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/' STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles") STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'static') ] model.py from django.contrib.gis.db import models class shop(models.Model): name = models.CharField(max_length=80, serialize=True) address = models.CharField(max_length=80, serialize=True) distance = models.PositiveIntegerField() location = models.PointField() form.py `from django.contrib.gis import forms from mapwidgets.widgets import GooglePointFieldWidget from .models import shop class shopAdminForm(forms.ModelForm): class Meta: model = shop fields = 'all' widgets = { 'location': GooglePointFieldWidget,

    }`

views.py `from django.shortcuts import render from .forms import *

def shopview(request):

context = {}

form = shopAdminForm(request.POST or None)
if form.is_valid():
    form.save()

context['form'] = form
return render(request, "form.html", context)`

form.html `{% load static%}

shop {{ form.media }}
{% csrf_token %} {{ form.as_p }}
` please help me
erdem commented 4 years ago

@Sarthak77tiwari Your project static view not well configured.

https://docs.djangoproject.com/en/dev/howto/static-files/

After getting the tons of your messages from all platforms, I tested the widgets with latest version django views to make sure it works fine. There is no issue. Your django project has problems, not the widget.

Also, read this; https://stackoverflow.com/help/how-to-ask