0
'Django Rest Framework' kullanıyorum ve bir RestfulAPI oluşturmaya çalışıyorum. Ancak, DB'yi eşitlemek için 'makemigrations' yapmaya çalıştığımda yukarıdaki hatayı alıyorum.AttributeError: 'module' nesnesinin 'ListCreateAPIVIEW' özniteliği yok Django
from __future__ import unicode_literals
from django.db import models
# Create your models here.
class Animal(models.Model):
id = models.CharField(max_length=10, primary_key=True)
name = models.CharField(max_length=200)
gender = models.CharField(max_length=10)
breed = models.CharField(max_length=200)
adoption = models.CharField(max_length=10)
vaccines = models.CharField(max_length=20)
class Doctor(models.Model):
id= models.CharField(max_length=10, primary_key=True)
name = models.CharField(max_length=20)
İşte
olduğunu görüşlerim:
İşte benim modeldir
from django.contrib.auth.models import User, Group
from rest_framework import viewsets, generics
from cw.myStart.models import Animal
from cw.myStart.serializers import UserSerializer, GroupSerializer, AnimalSerialiser, DoctorSerealiser
from models import Animal, Doctor
class AnimalList(generics.ListCreateAPIVIEW):
queryset = Animal.objects.all()
serializer_class = AnimalSerialiser
class DoctorDetail(generics.RetrieveUpdateDestroyAPIView):
queryset = Doctor.objects.all()
serializer_class = DoctorSerealiser
İşte benim urls.py geçerli: önceden
from django.conf.urls import url, include
from rest_framework import routers
from rest_framework.urlpatterns import format_suffix_patterns
from cw.myStart import views
router = routers.DefaultRouter()
router.register(r'users', views.UserViewSet)
router.register(r'groups', views.GroupViewSet)
# Wire up our API using automatic URL routing.
# Additionally, we include login URLs for the browsable API.
urlpatterns = [
url(r'^', include(router.urls)),
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
url(r'^api/$', views.AnimalList.as_view()),
url(r'^api/(?P<pk>[0-9]+)/$', views.AnimalDetail.as_view()),
]
urlpatterns = format_suffix_patterns(urlpatterns)
teşekkürler. Bununla
class AnimalList(generics.ListCreateAPIVIEW):
: