Data binding error 'NoneType' does not support indexing

Hi Guys,
I want to put a news aggregator into my application that I am developing but for some reason I get an error that says:

Data Binding update failed with 1 error. Did you initialise all data binding sources before initialising this component?
Error binding [text of category_label](javascript:void(0)) to self.item[‘category’][‘name’]: 'NoneType' does not support indexing

The link to my work is:

The news aggregator is an form called ‘EzyTroubleshoot’ and it’s relevant pages are ‘ArticleEdit’ and ‘ArticleView’

What can I do to fix this. i have tried many things like going through my code, comparing it to the tutorial. It was working fine a few minutes ago, but it changed when i did something

In your Articles table you have a None in the Category column.

In your form you are trying to bind to text in the Categories table (which is linked to Articles).

Since there is a None, indexing that cell with self.item['category']['name'] leads to an error.

You will have to add some logic to filter what is returned to your repeating panel’s items, or adjust your data bindings accordingly in your template (ArticleView). You can even add some logic to the data bindings section in the IDE. For example, on your label, you could set the text binding as follows:

self.item['category']['name'] if self.item['category'] else ''

Lots of choices there for you to examine. Good luck with your development.

2 Likes

A post was split to a new topic: Data binding error