26👍
✅
You can achieve this without using raw SQL. Use the built in __
mechanism instead (see the documentation for more details). Something like this:
MyOrder.objects.filter(order_date__year = 2010)
6👍
you can use django’s builtin query API for this. no need for any vendor specific code or raw SQL.
it would probably look something like this:
Orders.objects.filter(order_date__year=2010)
👤ozk
- [Django]-Authenticate by IP address in Django
- [Django]-How can I chain Django's "in" and "iexact" queryset field lookups?
- [Django]-Itertools.groupby in a django template
Source:stackexchange.com