error <generator object Class.function at 0x7f6...>

Hi
I am new to code, and got this function to create table rows index number, in reverse order.

But i can’t make the loop return all values.

After a lot of searching i used yield but in front-end i get this error <generator object Class.function at 0x7f6...> i think it’s the RAM location of the loop instance item.

def render_serial_number(self):
        val = self.page.end_index()    # i did thought of using one of django.core.Paginator (count, num_pages and page_range)   
       
        for x in range(val, 0, -1):            
            print('x in range==>', x)  # x is fine here.                       
            yield x    # before i used return, but it's stop the loop at first item.
            x = x -1
            print('x', x)            

    
        self.serial_number = getattr(
            self, 'serial_number',  next(x)
            
        )
        return next(self.serial_number)

Many thanks
Ali

What are you trying to do here?

What does the view that is using this function look like?

This message:

Is not an error. It’s what a generator returns as a string representation. It’s an indication that you’re trying to use this incorrectly.