t_cat_id = t_cat.id
cursor.execute("select offered_item,offered_item_category_id from foundation_swaptable where accepted_item = %s", t_cat.id)
the code above throws the exception below:
'int' object has no attribute 'keys'
when I surround t_cat.id with square brackets as below:
cursor.execute("select offered_item,offered_item_category_id from foundation_swaptable where accepted_item = %s", [t_cat.id])
the error is gone.
where t_cat is an mptt category object which I fetch as below:
MpttCategory.objects.get(category_name=t_category)
and it has an id column in DB representation which is integer.
can anyone tell me why I get this exception. I just can't associate a meaning with the error.
please tell me if more info is needed..
ps. I am a little drunk :)
Like the documentation says, the second argument must be a sequence or mapping.
Related
I need to get the entered name in odoo model and get the first letters of each word in upper case. Ex: MTA Flushing from that I need to create MF as output. I tried it. But it gives the error "AttributeError: 'bool' object has no attribute 'split' "
Here is my code
my_name = self.env['my_details'].search([('id', '=',so_id )]).name
my_d_name = "".join([i[0].upper() for i in depot_name.split()])
Any idea to solve this???
i[0] is False for some value in your database.
This should work:
my_d_name = "".join([i[0].upper() for i in depot_name.split() if i[0]])
Thanks for help..
In my case first have to convert the name that searched into string and then we can apply the code without getting errors.
my_name = self.env['my_details'].search([('id', '=',so_id )]).name
str_name = str(my_name)
my_d_name = "".join([i[0].upper() for i in my_name.split()])
I'm trying to register an new Transaction object on the DB using Django, but I'm having TypeError: expected string or bytes-like object when I try to do user_id = user.id I can't really understand why this is happening, since I do the same steps when registering a new Bank object (as shown on prints below). I've tried to debug and the local variables have the correct value, I've also tried to cast user.id with string or int, but none of them worked.
traceback console error create Transaction method create Bank method
models.py
Firstly, please don't post code or errors as images; they are text, they should be posted as text in the question.
However I don't see anything in any of those snippets that suggest the error is with the user - that line is probably highlighted because it's the last in that multi-line call.
Rather, the error looks to be in the reference to date.today - if that's the datetime.date class, then today is a method, which you would need to call:
Transaction.objects.create(date=date.today(), ... )
Or, since that field has a default anyway, you could leave out the date attribute from the create call altogether.
I am working on a tool for Jira using the python-jira library.
def find_ticket_key_by_name(search_string):
global jira
result = jira.search_issues('project=FSA and status != Done and summary ~ "HOST TESTER-APP:SERVICE1-SERVICECOUNT" order by createdDate', maxResults=1)
return result
The function above successfully returns a jira object
[<JIRA Issue: key=u'FSA-11', id=u'119060'>]
however if I attempt to print the key value
result.key
I get this error
AttributeError: 'ResultList' object has no attribute 'key'
I found the problem and posting solution in case somebody gets stuck like me.
In my case I am only returning one result and I assumed it will return one object.
This is not the case as indicated by the "ResultList" error. Even if you return 1 result the function will still return a list with 1 result.
What you are getting is a List in python, so try the following:-
result[0].key to get the key value
result[0].id to get id value.
You can always check type any data using type keyword, in your case it will be class 'jira.client.ResultList' which is a List object
If you want to get the key of issue you searched,
if result:
for issue in result:
print(issue.key)
It should help.
As in the title, I'm getting
AttributeError: 'str' object has no attribute 'regex'
I've seen many valid answers to this, but none of them applied to my code as they identified issues in the urls.py file. My issue is in the views.py file.
I get the exception when using reverse to generate a redirect URL:
HttpResponseRedirect(reverse('changetracker:detail', args))
When I use 'changetracker:detail' in other functions, I don't get the exception.
I'm answering this to share knowledge as I didn't see this particular root cause identified already.
The problem turned out to be that I should be using a keyword argument 'args=args' to pass in URL arguments, not a positional argument:
HttpResponseRedirect(reverse('changetracker:detail', args=args))
Using the positional argument (position 2) caused reverse to use that argument as the URL list and thus raise the AttributeError.
I'm building a Bar-code manager and need to get the field value from the form. My test looks like like:
res = self._columns['rsid']
_logger.error("the result is : %d",% (res))
raise osv.except_osv(_("Test"), _(res._type))
But in the log in found it says: "the result is : openerp.osv.field.char object ox898943".
In the window it says char.
The type of the field rsid I defined is char.
Why is it doing this?
the field in the form was declared as an openobject field, that's why you see it as an osv.field. Anyway, it is a char as well, and you can read it and manipulate it as a char object
To view the info message in an osv exception do this:
message='type: %s' % res._type
_logger.error("the result is : %d",% (res))
raise osv.except_osv(_("Test"), _(message))