Here are my codes:
serializers.py
class UserSerializer(serializers.ModelSerializer): class Meta: model = User fields = ( 'username', 'email') class AllListingSerializer(serializers.ModelSerializer): class Meta: model = Listing fields = ('name', 'desc', 'thumbnail', 'office_no', 'mobile_no', 'email', 'web ')
views.py
class UserViewSet(generics.ListCreateAPIView): queryset = User.objects.all() serializer_class = UserSerializer class AllListing(generics.ListCreateAPIView): queryset = Listing.objects.all() serializer_class = AllListingSerializer
urls.py
urlpatterns = patterns('', url(r'^$', apiview.UserViewSet), url(r'^listings/$', apiview.AllListing), )
But when I get the base url, it shows
init () takes 1 positional argument, but 2 are given
and when I go to '/ listings /' url, I get 404 Page not found, but I have several entries in db.
I am new to django. I canβt understand what is wrong with them. I am using Django 1.7.1 in virtualwrappr, python 3.4.
source share