Re: django Object not iterable error

2015-06-15 Thread Shekar Tippur

>
> Thank you! Thank you! Thank you!


Sometimes I miss the most obvious things.

Thanks again.

- Shekar 

-- 
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/682c0bd1-1937-4348-a2c3-a1dc2d969081%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django Object not iterable error

2015-06-15 Thread James Schneider
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  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[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.


Re: django Object not iterable error

2015-06-15 Thread Shekar Tippur
Here my urls.py

urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^product/$', productviews, productviews.ProductList.as_view()),
url(r'^product/(?P[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.


Re: django Object not iterable error

2015-06-15 Thread Vijay Khemlani
No, you need to post the parts of your code that may have triggered the
error.

In this case, your urls.py and the method in your views.py that handles the
request probably.

On Mon, Jun 15, 2015 at 9:32 PM, Shekar Tippur  wrote:

> James,
>
> Is this what you mean?
>
> - Shekar
>
>
>> Environment:Request Method: POSTRequest URL: 
>> http://127.0.0.1:8000/product/Django Version: 1.8.2Python Version: 
>> 3.4.3Installed Applications:('django.contrib.admin', 'django.contrib.auth', 
>> 'django.contrib.contenttypes', 'django.contrib.sessions', 
>> 'django.contrib.messages', 'django.contrib.staticfiles', 
>> 'product',)Installed Middleware:('disable.DisableCSRF', 
>> 'django.contrib.sessions.middleware.SessionMiddleware', 
>> 'django.middleware.common.CommonMiddleware', 
>> 'django.middleware.csrf.CsrfViewMiddleware', 
>> 'django.contrib.auth.middleware.AuthenticationMiddleware', 
>> 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 
>> 'django.contrib.messages.middleware.MessageMiddleware', 
>> 'django.middleware.clickjacking.XFrameOptionsMiddleware', 
>> 'django.middleware.security.SecurityMiddleware')Traceback:File 
>> "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/core/handlers/base.py"
>>  in get_response  119. resolver_match = 
>> resolver.resolve(request.path_info)File 
>> "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/core/urlresolvers.py"
>>  in resolve  368. sub_match = 
>> pattern.resolve(new_path)File 
>> "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/core/urlresolvers.py"
>>  in resolve  238. kwargs.update(self.default_args)Exception 
>> Type: TypeError at /product/Exception Value: 'function' object is not 
>> iterable
>>>
>>>   --
> 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/a5df84ec-2d2f-47ef-bdef-4cbbfaa7406b%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/CALn3ei0WdSBgfSwnnFGcp%2BacFQMm0AXyTFbf4fWOLLnBhf%2B9_Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django Object not iterable error

2015-06-15 Thread Shekar Tippur
James,

Is this what you mean?

- Shekar
 

> Environment:Request Method: POSTRequest URL: 
> http://127.0.0.1:8000/product/Django Version: 1.8.2Python Version: 
> 3.4.3Installed Applications:('django.contrib.admin', 'django.contrib.auth', 
> 'django.contrib.contenttypes', 'django.contrib.sessions', 
> 'django.contrib.messages', 'django.contrib.staticfiles', 'product',)Installed 
> Middleware:('disable.DisableCSRF', 
> 'django.contrib.sessions.middleware.SessionMiddleware', 
> 'django.middleware.common.CommonMiddleware', 
> 'django.middleware.csrf.CsrfViewMiddleware', 
> 'django.contrib.auth.middleware.AuthenticationMiddleware', 
> 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 
> 'django.contrib.messages.middleware.MessageMiddleware', 
> 'django.middleware.clickjacking.XFrameOptionsMiddleware', 
> 'django.middleware.security.SecurityMiddleware')Traceback:File 
> "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/core/handlers/base.py"
>  in get_response  119. resolver_match = 
> resolver.resolve(request.path_info)File 
> "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/core/urlresolvers.py"
>  in resolve  368. sub_match = 
> pattern.resolve(new_path)File 
> "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/core/urlresolvers.py"
>  in resolve  238. kwargs.update(self.default_args)Exception Type: 
> TypeError at /product/Exception Value: 'function' object is not iterable
>>
>> 

-- 
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/a5df84ec-2d2f-47ef-bdef-4cbbfaa7406b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django Object not iterable error

2015-06-15 Thread James Schneider
Can you post the entire stack trace? You may have to run a bit up the chain
in the race to track down the problem.

-James
On Jun 15, 2015 2:40 PM, "Shekar Tippur"  wrote:

>
>
>
> Hello,
>
> This maybe a generic question. How do I troubleshoot something like this.
> The stacktrace is not really helpful as it does not point to the code that
> is causing this issue.
>
> TypeError at /product/
>
> 'function' object is not iterable
>
> Request Method:POSTRequest URL:http://127.0.0.1:8000/product/Django
> Version:1.8.2Exception Type:TypeErrorException Value:
>
> 'function' object is not iterable
>
> Exception 
> Location:/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/core/urlresolvers.py
> in resolve, line 238Python Executable:
> /Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4Python
> Version:3.4.3Python Path:
>
> ['/Users/ctippur/PycharmProjects/project1',
>  '/Users/ctippur/PycharmProjects/project1',
>  '/Library/Frameworks/Python.framework/Versions/3.4/lib/python34.zip',
>  '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4',
>  
> '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/plat-darwin',
>  
> '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/lib-dynload',
>  
> '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages'
>
>
> - Shekar
>
>  --
> 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/3d689375-1afe-448e-95b4-54ecbab2cd77%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%2BciVh7fmPgHuvD9KHjDz6pSJG2zoa1dsW1PffvBf%3DUV4iqQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


django Object not iterable error

2015-06-15 Thread Shekar Tippur



Hello,

This maybe a generic question. How do I troubleshoot something like this. 
The stacktrace is not really helpful as it does not point to the code that 
is causing this issue.

TypeError at /product/

'function' object is not iterable

Request Method:POSTRequest URL:http://127.0.0.1:8000/product/Django Version:
1.8.2Exception Type:TypeErrorException Value:

'function' object is not iterable

Exception 
Location:/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/core/urlresolvers.py
 
in resolve, line 238Python Executable:
/Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4Python 
Version:3.4.3Python Path:

['/Users/ctippur/PycharmProjects/project1',
 '/Users/ctippur/PycharmProjects/project1',
 '/Library/Frameworks/Python.framework/Versions/3.4/lib/python34.zip',
 '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4',
 '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/plat-darwin',
 '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/lib-dynload',
 '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages'


- Shekar

-- 
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/3d689375-1afe-448e-95b4-54ecbab2cd77%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.