1👍
In case of DateTimeField
to filter by date you can write something like this:
Model.objects.filter(
start_date__year=dateobj.year,
start_date__month=dateobj.month,
start_date__day=dateobj.day
)
0👍
I think you want to know how to use an expression as a keyword for a named argument. Do this by creating a dictionary (where you can use expressions for keys) then splat it into the method arguments:
kwargs = {
start_date_date.date(): start_date
}
Model.objects.filter(**kwargs)
But your question is not entirely clear because start_date_date.date()
seems wrong anyway.
- [Answer]-Django admin filter data after selection
- [Answer]-How to refer to extJS combobox using a string?
- [Answer]-How to set 'next' parameter via extra_context in Django
Source:stackexchange.com