类型错误:无法在Django中将GeoQueryset对象转换为str implicilty

时间:2015-07-14 04:38:23

标签: django geodjango

我关注this tutorial。它在我的视图函数中显示错误

  

类型错误:无法将Geoqueryset对象隐式转换为str

我的观看功能是

def index(request):
    'Display map'
    waypoints = WayPoint.objects.order_by('name')
    return render_to_response('waypoints/index.html', {
        'title': 'Waypoints Tutorial',
        'waypoints': waypoints,
        'content': render_to_string('waypoints/waypoints.html', {'waypoints': waypoints}),
    })

在最后一行显示错误

  

内容':render_to_string(' waypoints / waypoints.html',{'航路点':航路点})

我的waypoints.html

{% for waypoint in waypoints %}
    <div id="{{waypoint.id}}" class="waypoint">
        {{ waypoint.name }} ({{waypoint.geometry.y}} , {{waypoint.geometry.x }})
    </div>
{% endfor %}

跟踪附件

Environment:


Request Method: GET
Request URL: http://127.0.0.1:8080/

Django Version: 1.8.3
Python Version: 3.3.5
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.gis',
'waypoints')
Installed Middleware:
 ('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware')


Traceback:
  File "C:\Python33\lib\site-packages\django\core\handlers\base.py" in    get_response
  132.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "E:\Kcube\Django\leafletmaps\waypoints\views.py" in index
  17.         'content': render_to_string('waypoints/waypoints.html', {'waypoints': waypoints}),
  File "C:\Python33\lib\site-packages\django\shortcuts.py" in render_to_response
  39.         content = loader.render_to_string(template_name, context, using=using)
  File "C:\Python33\lib\site-packages\django\template\loader.py" in render_to_string
  99.         return template.render(context, request)
  File "C:\Python33\lib\site-packages\django\template\backends\django.py" in render
  74.         return self.template.render(context)
  File "C:\Python33\lib\site-packages\django\template\base.py" in render
  209.                     return self._render(context)
  File "C:\Python33\lib\site-packages\django\template\base.py" in _render
  201.         return self.nodelist.render(context)
  File "C:\Python33\lib\site-packages\django\template\base.py" in render
  903.                 bit = self.render_node(node, context)
  File "C:\Python33\lib\site-packages\django\template\base.py" in render_node
  917.         return node.render(context)
  File "C:\Python33\lib\site-packages\django\template\defaulttags.py" in render
  499.                     url = reverse(project_name + '.' + view_name,

  Exception Type: TypeError at /
  Exception Value: Can't convert 'GeoQuerySet' object to str implicitly

0 个答案:

没有答案