没有Auth的Django REST框架

时间:2014-01-29 09:54:38

标签: python django django-rest-framework

我尝试使用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'] 

有什么想法吗?

0 个答案:

没有答案