我尝试使用Django REST框架创建一个基本视图,而不需要身份验证。
Settings.py
THIRD_PARTY_APPS = (
'south', # Database migration helpers:
'crispy_forms', # Form layouts
'rest_framework',
)
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.AllowAny',
)
}
urls.py
router = routers.DefaultRouter()
router.register(r'ticket', views.TicketViewSet)
urlpatterns = patterns('',
url(r'^', include(router.urls)),
url(r'^test', include('rest_framework.urls', namespace='rest_framework')),
)
串行器
from django.contrib.auth.models import User, Group
from rest_framework import serializers
class TicketInputSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Abc
fields = ('test')
模型
from django.db import models
class Abc(models.Model):
test = models.CharField(max_length=12)
错误
当试图获取URI时,我得到以下内容,
Page Not Found 404
Using the URLconf defined in config.urls, Django tried these URL patterns, in this order:
^test ^login/$ [name='login']
^test ^logout/$ [name='logout']
有什么想法吗?