1👍
✅
Unfortunately there isn’t a good way to do this at present, the best way is to use some raw SQL in conjunction with the extra() method and then call distinct().
2👍
Do you want to get the hours from a datetime object? Which .dates()
do you mean?
hour = instance.yourDateTimeField.hour
- [Django]-Django-admin.py makemessages does not create .po files
- [Django]-How to tag whole ViewSet in drf_yasg?
- [Django]-How can I add javascript file to my ModelForm in django?
- [Django]-How to provide a source directory in the [tool.django-stubs] directive of a pyproject.tom file?
- [Django]-How can you exclude an item in the query set while in a for loop?
1👍
I have created this code in order to manually do it.
hours = []
for h in objects.values('start_date'):
hours.append(h['start_date'].hour)
tempdict = {}
for x in hours:
tempdict[x] = x
hours = tempdict.values()
hours.sort()
- [Django]-Django query equivalent of MySQL GREATEST function?
- [Django]-Running Python file from Django views
- [Django]-Youtube Plugin for Django Ckeditor Updated
- [Django]-Django: better to save a slug to the DB or generate dynamically, if used for lookup?
- [Django]-Format numbers in Django with Intcomma
- [Django]-Is this how django does Single Table Inheritance?
- [Django]-A new user can login after registering until i manually change the password in admin console
- [Django]-Django: Count only the latest object after grouping by month
- [Django]-Django .."join" query?
Source:stackexchange.com