django rest_framework viewset has no route -


i started new django application django rest_framework. 1 thing odd though - when try example quickstart works fine: route @ http://localhost:8000/users/ can query. doesn't work own app minimal be. route http://localhost:8000/listings/ not available , no error. i'm using django 1.8.2 , djangorestframework 3.1.3.

settings.py:

#... installed_apps = (     'django.contrib.admin',     'django.contrib.auth',     'django.contrib.contenttypes',     'django.contrib.sessions',     'django.contrib.messages',     'django.contrib.staticfiles',     'rest_framework',     'rest_framework_swagger',     'debug_toolbar',     'listing', ) rest_framework = {     # use django's standard `django.contrib.auth` permissions,     # or allow read-only access unauthenticated users.     'default_permission_classes': [         'rest_framework.permissions.djangomodelpermissionsoranonreadonly'     ]  } #... 

urls.py:

from rest_framework import routers, serializers, viewsets listing.models import listing   class listingserializer(serializers.hyperlinkedmodelserializer):     class meta:         model = listing         fields = ('description',)   class listingviewset(viewsets.viewset):     queryset = listing.objects.all()     serializer_class = listingserializer   router = routers.defaultrouter() router.register(r'listings', listingviewset)  urlpatterns = router.urls 

models.py:

from django.db import models   class listing(models.model):     description = models.textfield() 

edit:

the error:

page not found (404) request method:     request url:    http://127.0.0.1:8000/listings/  using urlconf defined in djangoway.urls, django tried these url patterns, in order:      ^__debug__/     ^$ [name='api-root']     ^\.(?p<format>[a-z0-9]+)$ [name='api-root']  current url, listings/, didn't match of these. 

edit: answered question , took code down, because there nothing odd it.

i should have used modelviewset:

class listingviewset(viewsets.modelviewset):                               ^^^^^ 

thanks xordoquy pointing out in issue opened.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -