[Fixed]-How to add URL strings for a Django app to a database and randomly select?

1👍

Well, I suppose you can make a new model something like this:

class Survey(model.Model):
  name = models.Charfield(max_length=50) # surveyone goes here
  ...

than in the view you can pull the random like this:

survey_count = Survey.objects.all().count()
random_survey_index = random.randint(0, survey_count - 1)

get the instance name by random_survey_index and append it to your url

Not sure how effective this approach is, but should work.

Leave a comment