Skip to content

Instantly share code, notes, and snippets.

@ciceroverneck
Created October 9, 2012 01:03
Show Gist options
  • Save ciceroverneck/3855943 to your computer and use it in GitHub Desktop.
Save ciceroverneck/3855943 to your computer and use it in GitHub Desktop.
Order + RAND() django ORM
from random import randint
from app.models import MyModel
MyModel.objects.raw('SELECT * FROM `app_mymodel` ORDER BY RAND(%d)'
% randint(0,99999))
@ciceroverneck
Copy link
Author

Guardo o valor do randint(0,99999) zé..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment