ここの例に従っています: http://django-tastypie.readthedocs.org/en/latest/tutorial.html My urls.py:
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')
私が得るエラーは次のとおりです。
/api/tours での不適切な設定
アクセスしようとすると:http://127.0.0.1:8000/api/tours?format=json
Entity_resource はどこから URL を取得しますか? 例にないよね?