That is what I meant, but the extra code is quite helpful. In your urls.py file you have this:
url(r'^product/$', productviews, productviews.ProductList.as_view()), when you probably want this: url(r'^product/$', productviews.ProductList.as_view()), You have an extra reference to 'productviews' as the second argument, which makes the URL resolver unhappy since it is now trying to execute the whole productviews module as a function. -James On Mon, Jun 15, 2015 at 5:58 PM, Shekar Tippur <ctip...@gmail.com> wrote: > Here my urls.py > > urlpatterns = [ > url(r'^admin/', include(admin.site.urls)), > url(r'^product/$', productviews, productviews.ProductList.as_view()), > url(r'^product/(?P<pk>[0-9]+)$', productviews.ProductDetail.as_view()), > ] > > > productviews.py > > > from product.models import Product > from product.serializers import ProductSerializer > from rest_framework import generics > from django.views.decorators.csrf import csrf_exempt > from django.utils.decorators import method_decorator > from django.http import HttpResponse > import json > > > class ProductList(generics.ListCreateAPIView): > queryset = Product > serializer_class = ProductSerializer > @method_decorator(csrf_exempt) > def post(self, request, *args, **kwargs): > received_json_data=json.loads(request.body.decode("utf8")) > serializer = ProductSerializer(data=received_json_data) > if serializer.is_valid(): > serializer.save() > print (request.body) > return HttpResponse('SUCCESS') > else: > print (serializer.errors) > return HttpResponse('Error') > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at http://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/3bd15344-357e-4a6c-a7a1-0a7ad5a1131d%40googlegroups.com. > > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2Be%2BciWMqxLb4fOB3kSGRckMiBrJm8%3DSEUHHY%2BjfVe40N4wSEQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.