daily pastebin goal
8%
SHARE
TWEET

Untitled

a guest Jul 17th, 2018 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from django.db import models
  2.  
  3. class MyModel(models.Model):
  4.     name = models.CharField(max_length=30)
  5.     result = models.IntegerField()
  6.    
  7. def MyView(request):
  8.     foo = MyModel.objects.order_by('result')
  9.     return render_to_response('foo.html', {'foo': foo})
  10.    
  11. def MyView(request):
  12.     foo = MyModel.objects.all()
  13.     foo = foo.extra(select={'result': 'CAST(result AS INTEGER)'}).extra(order_by = ['result'])
  14.     return render_to_response('foo.html', {'foo': foo})
  15.    
  16. def MyView(request):
  17.     foo = MyModel.objects.all()
  18.     foo = MyModel.objects.filter(result__gt = 50)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top