Closed r1bnc closed 3 years ago
Hello @r1bnc , thank you for your interest in the project.
Since the date range selector is "external" to the table, and potentially the underlying Model can have more than one DateField or DateTimeField, some assumption must be done on how to filter the queryset;
you can specify the field name to be addressed for filtering with the optional latest_by
attribute; the field doesn't need to shown as table column; when it is, it will receive a specific css class (probably something like "latest_by") so you can provide some feedback to the user by adding some style.
Il latest_by
attribute is not used, then the field will be inferred from the latest_by attribute of the Model.
At least, this is what I can remember now. Not sure about the format required for the dates value; probably 'YYYY-MM-DD'
I might be back to this point (and maybe improve the doc) as soon as I have the chance to check the code.
I currently use in my models.py: from django_unixdatetimefield import UnixDateTimeField class PlayerLog(models.Model): update_time = UnixDateTimeField() #stored in database as epoch time (1617966981)
When I use update_time
in views as the latest_by
. The code works but the output of the program doesnt have anything. The datatables just says: No data available in table
even though there should be.
Thank you for developing this program :D
The "build in" date range filter works on either a DateField or a DateTimeField. In your case, you might mimic it as follows: 1) collect the widget "date_from" and "date_to" values, and send them as "extra_data"; see: https://github.com/morlandi/django-ajax-datatable#17provide-extra-data-to-narrow-down-the-initial-queryset 2) override get_initial_queryset() to filter your queryset accordingly
Ok, I will try to do it.
I just changed my model to DateTimeField and now it works :D Thanks for the help.
Closing this issue now
Oh wait, how do I combine 'Export' buttons and Date Range. One seems to conflict tot the other. Enabling dom: 'Bfrtip',
on html removes date range but enables export button -_-
ok found it: dom: '<"toolbar">Blfrtip',
New problem. I have textfield data that has Name>
and it does not show up in the rendered tables. I think it is being read as HTML?
Example:
data content in database: <Name> the quick brown fox
rendered by this app: the quick brown fox
How do I fix this?
How do I disable html rendering on a single column and parse raw data from the database. fixed with: escape (value)
Please implement html escaping on the data values.
Some problem with the date range again. It works on sqlite (records are shown) but not when the database is Mariadb (MySQL) (No records found).
The sqlite database has the raw data in database, when you open sqlite3 database on a program: 2021-02-23 12:18:24
The mariadb has this raw data (when you open mysql client and select row from table in database): 2021-02-23 12:18:24.000000
Do this make the date range not work?
^ That issue I believe is a mismatch between TIME_ZONE. More clarification is needed.
The date range problem was fixed by copying the def filter_queryset_by_date_range(self, date_from, date_to, qs):
from the stock program code to my views py.
Oh yeah, how do I implement date time range filter? or just adding time filter at the existing date range
I am requesting this as feature request.
I tried to implement date range on my app but it does not work, always "No data in table". Does it needs to have specific date format? (YYYY-MM-DD HH:mm:SS)? From what I understand, all you need is to provide column data with date on it (
latest_by = "date_time"
).Thank You for this project.