我正在尝试使用用户在 Geodjango 中的位置创建 google map API 3 标记。
Internal Server Error 500
我在渲染谷歌地图和标记时遇到。在 CMD 控制台上,我得到TypeError: 'GeoQuerySet' object is not callable
.
您能否提出解决方案并解释异常的原因?
这views.py
class MyView(View):
def get(self, request):
resp = UserList.objects.all().values('nickname', 'last_location')
print (resp)
return JsonResponse(request, resp, safe=False)
这urls.py
from django.conf.urls import include, url
from django.contrib import admin
from mymap_app import views as map_views
admin.autodiscover()
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^my_endpoint/$',map_views.MyView.as_view(),name='user_list'),
url(r'^$',map_views.IndexView.as_view(), name='index'),
]
追溯:
Traceback (most recent call last):
File "C:\Python35-32\lib\site-packages\django\core\handlers\exception.py", lin
e 41, in inner
response = get_response(request)
File "C:\Python35-32\lib\site-packages\django\core\handlers\base.py", line 187
, in _get_response
response = self.process_exception_by_middleware(e, request)
File "C:\Python35-32\lib\site-packages\django\core\handlers\base.py", line 185
, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Python35-32\lib\site-packages\django\views\generic\base.py", line 68,
in view
return self.dispatch(request, *args, **kwargs)
File "C:\Python35-32\lib\site-packages\django\views\generic\base.py", line 88,
in dispatch
return handler(request, *args, **kwargs)
File "C:\Users\Kaleab\Desktop\WebMap\AAmap_Project\mymap_app\views.py", line 2
1, in get
return JsonResponse(request, resp, safe=False)
File "C:\Python35-32\lib\site-packages\django\http\response.py", line 530, in
__init__
data = json.dumps(data, cls=encoder, **json_dumps_params)
File "C:\Python35-32\lib\json\__init__.py", line 237, in dumps
**kw).encode(obj)
TypeError: 'GeoQuerySet' object is not callable
[05/Sep/2017 22:36:45] "GET /my_endpoint/ HTTP/1.1" 500 18865