Error when trying to reference Event.customer: `TypeError: string indices must be integers`
See original GitHub issueDescribe the bug Hi guys, first of all, thank you for your amazing work on this lib. This is an amazing tool!
Secondly, I’m trying to reference the customer
attribute of the Event
model and I’m getting this error:
>>> Event.objects.last().customer
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.7/code.py", line 90, in runcode
exec(code, self.locals)
File "<console>", line 1, in <module>
File "/app/.heroku/python/lib/python3.7/site-packages/djstripe/models/core.py", line 1492, in customer
data = self.data["object"]
TypeError: string indices must be integers
>>>
To Reproduce To reproduce, instantiate a Event and reference the customer using dot notation like this:
evt = Event.objects.first() evt.customer
The TypeError
should be raised.
Thank you!
Software versions
- Dj-Stripe version: 2.4.1
- Python version: 3.7
- Django version: 2.2
- Stripe API version: Latest
- Database type and version: PostgreSQL 11.10
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Python typeerror: string indices must be integers Solution
String indices must be integers. This means that when you're accessing an iterable object like a string, you must do it using a...
Read more >TypeError String Indices Must be Integers Python Error [Solved]
If you encounter this error message, double check to make sure you are using the numerical index value to access elements instead of...
Read more >Why am I seeing "TypeError: string indices must be integers"?
So I'd first check your data variable to see what you received there; I guess that data is a list of strings (or...
Read more >TypeError: list indices must be integers or slices, not str
This type error occurs when indexing a list with anything other than integers or slices, as the error mentions. Usually, the most straightforward...
Read more >TypeError: string indices must be integers, not str #21480
Occasionaly during highstate i got error (it looks like it occur on random machine with random time): Salt highstate error: Traceback (most ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks. Weird, this shouldn’t be a string. Would like to understand why it stored it as one, but also it shouldn’t error like this if it finds a string.
Closing this as user error then, but also we’re moving to just entirely native jsonfields with 2.6.0 with a migration path to the new fields in 2.8.