1👍
✅
Your showopen
variable isn’t in the four options provided by your code. If you don’t have a debugger to see what the variable actually is, then add some print statements to your code that print the variable to the console.
update_grp = User_Groups.objects.get(user_id=request.user.id)
showopen = update_grp.profilegroup
print showopen
#..
0👍
You’re missing an ‘else’ clause so the interpretator sees there could be a case where ‘slidercategory’ isn’t available within the scope of your function (where non of the if statements are matched).
Either add an else clause or assign sliderproduct = ‘somedefaultvalue’ at the top of your function, another solution would be to move the return bar into the if clauses their scopes, which would result in a None being returned when none of the ifs are matched.
>>> def test(foo):
... if foo == 2:
... bar = 'hello'
... elif foo == 3:
... bar = 'goodbye'
... return bar
>>> test(2)
>>> 'hello'
>>> test(1)
UnboundLocalError: local variable 'bar' referenced before assignment
- [Answer]-Django infinite loop to access models
- [Answer]-ViewDoesNotExist django
- [Answer]-Django 1.5 loses data from a form
- [Answer]-Django + InnoDB: random failure of model reading
- [Answer]-Getting data from other database
Source:stackexchange.com