Question: how can i query the checkin from a specific user in the api? Like a join with the user and filter by the user\_id? It because checkin does not have user\_id property.

Answer: 
Answering your question about datetime as a dictionary key:

Yes, time object of datetime can be used as dictionary key.

Conditions to use an object as a dictionary key:

> 
> To be used as a dictionary key, an object must support the hash function (e.g. through `__hash__`), equality comparison (e.g. through `__eq__` or `__cmp__`)(...)
> 
> 
> 

(Source: [DictionaryKeys](https://wiki.python.org/moin/DictionaryKeys))

datetime support for cited conditions:

> 
> Supported operations:
> 
> 
> ...
> 
> 
> * hash, use as dict key
> 
> 
> 

(Source: [datetime - time Objects](https://docs.python.org/2/library/datetime.html#time-objects))

However, you are getting this exception because dict `usage_dict_hourly` is empty.

`usage_dict_hourly` is initiated with `{}`. So, when you try to look for the element with key `time_now` in your function `constructing_dict`, it raises `KeyError` exception, because that key has not been found.
You aren't actually setting `useage_dict_hourly` to any value that way, that's your error.
You should ideally do something like:

```
useage_dict_hourly[time_now] = None
date_wise_dict[useage_dict_hourly[time_now]] = data_int

```

Or, better yet, just use datetime.datetime.now() as the key:

```
datetime_wise_date[datetime.datetime.now()] = data_int.

```

This way, there is no possibility of clashes in the value (which is possible - though unlikely - for useage\_dict\_hourly)