question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when trying to reference Event.customer: `TypeError: string indices must be integers`

See original GitHub issue

Describe 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:closed
  • Created 3 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jleclanchecommented, Feb 9, 2021

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.

0reactions
jleclanchecommented, Jan 14, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found