0
我在这里继例如:http://django-tastypie.readthedocs.org/en/latest/tutorial.html 我的urls.py:问题测试的Django tastypie
from django.conf.urls import patterns, include, url
from django.contrib import admin
from django.conf.urls.defaults import *
from ristoturisto.api import EntryResource
entry_resource = EntryResource()
admin.autodiscover()
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
(r'^blog/', include('ristoturisto.urls')), #this basically points to it self?
(r'^api/', include(EntryResource.urls)),
)
api.py
from tastypie.resources import ModelResource
from locations.models import tours
class EntryResource(ModelResource):
class Meta:
queryset = tours.objects.all()
resource_name = 'Tours'
型号:
class tours(models.Model):
name = models.CharField(max_length=255)
categories = models.ForeignKey('categories')
icon = models.CharField(max_length=255)
publishdate = models.CharField(max_length=255)
locations = models.ManyToManyField('geolocations')
我得到的错误是:
ImproperlyConfigured在/ API /旅游
当我试图访问:http://127.0.0.1:8000/api/tours?format=json
哪里Entity_resource得到它的URL从公司?这不是在这个例子中?
老天爷你是对的!我现在有一个新的错误,但是,谢谢你,为期两天......你的先生是一个真正的绅士! – R0b0tn1k
你使用任何代码检查器?我使用flake8,并在这种情况下通知我(例如,变量未使用)。 https://pypi.python.org/pypi/flake8 –