[Fixed]-A method to create for each user unique variables in views.py in Django

1👍

Do you really need to store variable names? This could be achieved by using python dictionaries.

d = {}
i = 0
while i < your_users_quantity:
    // generate your username (e.g.: user = "user_"+i that could result in user_1 for example)
    key = user
    // generate your value (e.g.: net_percent = whatever THIS user net_percent is)
    value = net_percent
    d[key] = value 
    i += 1

Then you just call d[‘user_1’] and you have the value of the net_percent that belongs to that user.

See this link for further reference on this useful structure: https://docs.python.org/2/tutorial/datastructures.html#dictionaries

Leave a comment