R0b0tn1k
R0b0tn1k

Reputation: 4306

Problems testing django tastypie

I'm following the example here: 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'

Models:

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')

The error i get is:

ImproperlyConfigured at /api/tours

When i try to access: http://127.0.0.1:8000/api/tours?format=json

Where does Entity_resource get it's URL's from? It's not in the example?

Upvotes: 0

Views: 151

Answers (1)

Andrei Kaigorodov
Andrei Kaigorodov

Reputation: 2165

You use the class EntryResource instead of the instance of this class entry_resource:

(r'^api/', include(EntryResource.urls)),

change it:

(r'^api/', include(entry_resource.urls)),

Upvotes: 1

Related Questions