When I try to call my custom django command with a id as a string it works without a problem.
call_command(COMMAND, '-i', '23')
But when I try to cast the id of a object to a string, then it will not work.
call_command(COMMAND, '-i', str(product.id))
It become this error:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/kombu/utils/__init__.py", line 423, in __call__
return self.__value__
AttributeError: 'ChannelPromise' object has no attribute '__value__'
Any idea why this is happening?
This function is inside a test, adding #override_settings(DEBUG=True) helped. The command is calling a task, so I had to made sure that it's not triggering the task.delay
Still strange that it worked with just putting the string as a parameter...
Related
I am starting working on GraphQL and as I am from python background I am using GraphQL with Python.
I followed the steps provided here Link but I am still facing issues.
An error occurred while resolving field Query.hello
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/graphql/execution/executor.py", line 311, in resolve_or_error
return executor.execute(resolve_fn, source, info, **args)
File "/usr/local/lib/python3.5/dist-packages/graphql/execution/executors/sync.py", line 7, in execute
return fn(*args, **kwargs)
TypeError: resolve_hello() missing 2 required positional arguments: 'context' and 'info'
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/graphql/execution/executor.py", line 330, in complete_value_catching_error
exe_context, return_type, field_asts, info, result)
File "/usr/local/lib/python3.5/dist-packages/graphql/execution/executor.py", line 383, in complete_value
raise GraphQLLocatedError(field_asts, original_error=result)
graphql.error.located_error.GraphQLLocatedError: resolve_hello() missing 2 required positional arguments: 'context' and 'info'
None
Please, help me resolve the issue.
It looks like the graphQL documentation is out of date. Graphene-python 2 changed the method signature. Try something like this instead
def resolve_hello(self, info, **kwargs):
return 'Hello world!'
You are not giving much information here, maybe the code that triggers the error would be helpful, but googling I found some related posts
https://github.com/graphql-python/graphene/issues/601
https://github.com/graphql-python/graphene-django/issues/282
Maybe check the versions that you are using as they mention on the first link
Try to like this one concept example on date:
Graphql required positional arguments
info,and **kwarg
def resolve_generated_date(self, info, **kwargs):
created_date = self.created_at.strftime('%Y-%m-%d')
return created_date
I found this script on the internet:
https://gist.github.com/gavsmi/dd31746e5847300b62da
Any idea why I am getting the following error message? It looks like a syntax error. I am still new to Python, so please help me point out what the problem is and how to fix it.
[root#ip-172-31-18-97 tmppython]# python snapshot.py
INFO:root:Finding snapshot for tag...
Traceback (most recent call last):
File "snapshot.py", line 164, in <module>
main()
File "snapshot.py", line 30, in main
snapshot = find_snapshot(args.tag_name, args.tag_value)
File "snapshot.py", line 47, in find_snapshot
snapshots = conn.get_all_snapshots(filters={'tag:' + tag_name: tag_value})
TypeError: cannot concatenate 'str' and 'NoneType' objects
You likely are not providing a 'tag_name' command line argument when running your script. Added arguments default to None in the argparse module, so 'args.tag_name' ('tag_name' in the scope where the error occurs) will be None unless you give it a value via the command line. If it is not clear, the “cannot concatenate 'str' and 'NoneType' objects” run-time error results from the attempted concatenation "'tag:' + tag_name", where 'tag_name' is None.
Recently I've got this problem in my application:
File "main.py", line 31,
in File "app.pyc", line 205, in run
TypeError: 'NoneType' object is not callable"
My code:
xml = EXML()
for pid, product in store.products.items():
xml.addRow()
xml.addCell((product['name']).encode('utf-8'), "String")
xml.addCell((product['symbol']).encode('utf-8'), "String")
xml.addCell((product['brand_name']).encode('utf-8'), "String") # line 205
xml.addCell(str(product['price']), "String")
Python 2.7 32-bit
It's wired, because this showed up after ~1000 iterations, with out any previus problem.
This application scans online store to get current prices.
Firstly I thought that somewhere I missed someting, and as result there is None.encode('utf-8'), but no, and "".encode('utf-8') seems to work. Moreover, I can't reproduce this error on testing site, just sometimes shows up while hard-working with ~2500 products.
What are possible other sources of this error?
>>> None.encode
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'encode'
>>> None()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not callable
On the given line you would have to set one of the two functions called to None somehow. Are you sure it's not the next line, because overwriting str is a rather common error.
OK, solved, it's bit bizzare, but this error is caused by product['brand_name'] which is sometimes BeautifulSoup.tag ( tag this time ) instead of BeautifulSoup.NavigableString as I planned. I still don't understad why and wtf ?
Anywat, great thanks for response. :)
I'm posting this question (and answer) so if anybody else has this problem in the future, you'll be able to google it.
If you are trying to run celeryd in Django like so:
python manage.py celeryd
You can receive the following error immediately after it has started:
celery#eric-desktop-dev has started.
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_manager(settings)
<... snip ...>
File "/usr/local/lib/python2.6/dist-packages/amqplib-0.6.1-py2.6.egg/amqplib/client_0_8/connection.py", line 134, in __init__
self._x_start_ok(d, login_method, login_response, locale)
File "/usr/local/lib/python2.6/dist-packages/amqplib-0.6.1-py2.6.egg/amqplib/client_0_8/connection.py", line 704, in _x_start_ok
args.write_longstr(response)
File "/usr/local/lib/python2.6/dist-packages/amqplib-0.6.1-py2.6.egg/amqplib/client_0_8/serialization.py", line 352, in write_longstr
self.write_long(len(s))
TypeError: object of type 'NoneType' has no len()
A rather cryptic error message, with no real clue as to where to go to fix the problem. See below for the answer so you don't waste a bunch of time on this error like I did today :)
You're missing a celery setting in settings.py. In my case it was caused by a typo (I missed an 'S' in BROKER_PASSWORD). Double check you included all the required settings and that each one is spelled everything correctly, and you'll avoid making as ass of yourself like I did today :)
Why doesn't
import string;help(string.title)
seem to work but
help(string.strip)
works just fine?
I get the error
Traceback (most recent call last):
File "", line 1, in
AttributeError: 'module' object has no
attribute 'title'
title is a method on objects of type str, not a function in the string module. That means you can do "foo".title() or str.title("foo") but not string.title("foo").
help(str.title) seems to work just fine.