def assign_random_category(resource):
 random_index = randint(0, (TopicCategory.objects.all().count() - 1))
 tc = TopicCategory.objects.all()[random_index]
 resource.category = tc
 resource.save()

def assign_random_category ( resource ) : random_index = randint ( 0 , ( TopicCategory . objects . all ( ) . count ( ) - 1 ) ) tc = TopicCategory . objects . all ( ) [ random_index ] resource . category = tc resource . save ( )
assign a random category to a resource .