What percentage would I have to spend on my rent?
According to the Bank of Spain, it is advisable not to allocate more than 35% of your money, either in a mortgage or in a rent. Even so, the most correct would be not to spend more than 25% of your salary on paying for the flat.
There is no magic formula and it depends on your situation. For example, perhaps if I live closer to work, I can afford to spend a little more of my income on my rent, as I won't have to spend it on transport.
Remember that the most important thing is to keep control of your finances!