0
我是Django的新手。當我在pycharm運行命令python manage.py runserver
,我得到這樣Django,匹配查詢不存在
2017-12-03 05:09:56,952 - INFO - server - Listening on endpoint
tcp:port=8000:interface=127.0.0.1
Internal Server Error:/
Traceback (most recent call last):
File "/Users/mac/anaconda/lib/python3.6/site-packages/django/core/handlers/exception.py", line 41, in innerresponse = get_response(request)
File "/Users/mac/anaconda/lib/python3.6/site-packages/django/core/handlers/base.py", line 187, in _get_response response = self.process_exception_by_middleware(e, request)
File "/Users/mac/anaconda/lib/python3.6/site-packages/channels/handler.py", line 243, in process_exception_by_middleware
return super(AsgiHandler,self).process_exception_by_middleware(exception, request)
File "/Users/mac/anaconda/lib/python3.6/site-packages/django/core/handlers/base.py", line 185, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/mac/PycharmProjects/590/flightmate/webapp/views.py", line 180, in index airlines = RecordSet.objects.get(name="airline")
File "/Users/mac/anaconda/lib/python3.6/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/Users/mac/anaconda/lib/python3.6/site-packages/django/db/models/query.py", line 380, in get self.model._meta.object_name
webapp.models.DoesNotExist: RecordSet matching query does not exist.
錯誤消息的models.py
的代碼是:
from __future__ import unicode_literals
import uuid
import datetime
from django.db import models
class RecordSet(models.Model):
name = models.CharField(max_length=512)
value = models.TextField()
def __unicode__(self):
return "{0}: {1}".format(self.name, self.value)
和models.py
的父目錄的目錄webapp
。任何建議表示讚賞,謝謝!
您應該在shell中添加錯誤堆棧。 –