Re: an elusive ValueError: 'str' object not callable -- lost.
On Wed, Jan 30, 2013 at 6:59 PM, Maurice Asimov wrote: > Hey guys. > > I recently started getting a ValueError complaining that an str is not > callable -- in a very wierd place. > > This happens to some calls to messages.info(request, 'somethingsomething'), > in one of those cases __inside the django console__ > > Any other ideas what's wrong? Anyone bumped into this? > > The same problem occured in part of the app I control, removing the call to > messages.info solved it. > > Anything at all? Thanks. > Somehow, you have overwritten the 'info' attribute of the django.messages module with a string, and so it blows up. Look for places where you assign to anything named 'info': ack "\Winfo.*=" ack "setattr\([^,]*,.*info" or grep -r "[^a-z_]info.*=" * grep -r "setattr([^,]*,.*info" * I know you said not to blame your custom middleware, but this does not happen with stock 1.4.2, so if you have this happening even in requests that do not touch your views, it most likely will be your middleware. It would be easy to test if you can reliably reproduce this in the admin site, simply disable the custom middleware and see if you can still reproduce the error. Cheers Tom -- 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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
an elusive ValueError: 'str' object not callable -- lost.
Hey guys. I recently started getting a ValueError complaining that an str is not callable -- in a very wierd place. This happens to some calls to messages.info(request, 'somethingsomething'), in one of those cases __inside the django console__ Traceback: Traceback: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response 111. response = callback(request, *callback_args, **callback_kwargs) File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/admin/options.py" in wrapper 366. return self.admin_site.admin_view(view)(*args, **kwargs) File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view 91. response = view_func(request, *args, **kwargs) File "/app/.heroku/python/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func 89. response = view_func(request, *args, **kwargs) File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/admin/sites.py" in inner 196. return view(request, *args, **kwargs) File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapper 25. return bound_func(*args, **kwargs) File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view 91. response = view_func(request, *args, **kwargs) File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/decorators.py" in bound_func 21. return func(self, *args2, **kwargs2) File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/admin/options.py" in changelist_view 1169. response = self.response_action(request, queryset=cl.get_query_set(request)) File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/admin/options.py" in response_action 908. response = func(self, request, queryset) File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/admin/actions.py" in delete_selected 49. "count": n, "items": model_ngettext(modeladmin.opts, n) File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/admin/options.py" in message_user 696. messages.info(request, message) Exception Type: TypeError at /admin/auth/user/ Exception Value: 'str' object is not callable More information: Environment: Request Method: POST Request URL: http://idpee.herokuapp.com/admin/auth/user/ Django Version: 1.4.2 Python Version: 2.7.3 Installed Applications: ('django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.admin', 'registration', 'idpee', 'oauth2app', 'social_auth', 'uni_form', 'south') Installed Middleware: ('django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'social_auth.middleware.SocialAuthExceptionMiddleware', '') The custom middleware is rather simple and non-intrusive, so _please_ don't just blow this off as "you screwed something up in your middleware". We're already looking at that, thanks. Any other ideas what's wrong? Anyone bumped into this? The same problem occured in part of the app I control, removing the call to messages.info solved it. Anything at all? Thanks. -- 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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: 'str' object not callable
On 26 oct, 17:45, John Yeukhon Wong wrote: > This is part of my views > > [[[code]]] from mysite.views > > def site_root(request): > return HttpResponse("This is the site root") > def hello(request): > return HttpResponse("Hello World") > > [[endcode]] > > My URLConf > [[code]] > from django.conf.urls.defaults import * > > urlpatterns = patterns('mysite.views', > (r'^$', 'site_root'), > (r'^hello/$', 'hello'), > (r'^now/plus/(\d{1,2})/$', > 'offset_time'), > ) > [[/code]] > > I am actually following the book "The Definitive Guide to Django (2)"" > chapter 8 advacne URLConf and views. > The sample code was > > [[code]] > from django.conf.urls.defaults import * > urlpatterns = patterns('mysite.views', > (r'^hello/$', 'hello'), > (r'^time/$', 'current_datetime'), > (r'^time/plus/(\d{1,2})/$', 'hours_ahead'), > ) > [[//code]] > > What is wrong with my url? > I am calling the root right now, localhost, and root view is the first > one to be called. That gives me the error, and thus any url thereafter > gives the same error. > > Any input is appreicated. Thanks Please post the full traceback. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
'str' object not callable
This is part of my views [[[code]]] from mysite.views def site_root(request): return HttpResponse("This is the site root") def hello(request): return HttpResponse("Hello World") [[endcode]] My URLConf [[code]] from django.conf.urls.defaults import * urlpatterns = patterns('mysite.views', (r'^$', 'site_root'), (r'^hello/$', 'hello'), (r'^now/plus/(\d{1,2})/$', 'offset_time'), ) [[/code]] I am actually following the book "The Definitive Guide to Django (2)"" chapter 8 advacne URLConf and views. The sample code was [[code]] from django.conf.urls.defaults import * urlpatterns = patterns('mysite.views', (r'^hello/$', 'hello'), (r'^time/$', 'current_datetime'), (r'^time/plus/(\d{1,2})/$', 'hours_ahead'), ) [[//code]] What is wrong with my url? I am calling the root right now, localhost, and root view is the first one to be called. That gives me the error, and thus any url thereafter gives the same error. Any input is appreicated. Thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: 'str' object not callable
Yes it's the URL. you are probably calling an incomplete view or wrong template name. Grant On 18 Jul 2009, at 09:29, adelaide_mike wrote: > > Hi > Can some kind soul tell me what, in principle, this means: > > 'str' object not callable > > ? It seems to be associated with urls.py > > Newbie just needs some additional words to help. Have looked at the > history of this, which did not help. I do not want to know why the > error is arising, I simply want to know what it is trying to tell me, > in good ol English (if possible). > > Thanks > > Mike > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
'str' object not callable
Hi Can some kind soul tell me what, in principle, this means: 'str' object not callable ? It seems to be associated with urls.py Newbie just needs some additional words to help. Have looked at the history of this, which did not help. I do not want to know why the error is arising, I simply want to know what it is trying to tell me, in good ol English (if possible). Thanks Mike --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---