Guest User

Untitled

a guest
Jul 17th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  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)
Add Comment
Please, Sign In to add comment