Created
May 21, 2017 17:47
-
-
Save kholidfu/91318708b2fc9aca9ec86aaa5119aaed to your computer and use it in GitHub Desktop.
get random id from django model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
from app.models import Collection | |
c = Collection.objects.filter(done=True).values('id') | |
rid = [i['id'] for i in c] | |
random.choice(rid) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment