-1

I have used a random function in python but its not working , I am very new at python. Please review below code

  def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context['number'] = random.randrange(1, 100)
        return context

its rertuning error NameError: name 'random' is not defined

VinothRaja
  • 1,405
  • 10
  • 21

1 Answers1

0

Probably, You did not import random module. Add this to the top of your script:

import random 
kaan bobac
  • 729
  • 4
  • 8