Skip to content

Conversation

@seulsale
Copy link
Contributor

Fixes: #8391

Set the default value to export installed_date values as empty when they are null

verbose_name='Side Z'
)
install_date = tables.DateColumn(
default=''
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately this approach removes the default placeholder (—) in the table when rendered in the UI, which we want to keep.

It looks like DateColumn inherits from TemplateColumn: The ideal fix for this might actually be to fix it upstream in django-tables2 by adding a value() method to DateColumn to better handle null values.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I agree in that it might be better to fix it upstream. This behavior will occur again in the case of exporting other null date fields, like date_added in the Aggregate model.

I can go and open an issue there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The django-tables2 library doesn't seem to very active at the moment.

What do you think of implementing a custom DateColumn and improving the handling of null values within the project?

It could be added into the utilities/tables.py module.

Copy link
Member

@jeremystretch jeremystretch Feb 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather avoid that, but it would be a reasonable short-term fix. Do you want me to keep #8391 assigned to you?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like it too much either, but sure it can be a short-term fix. Yes please keep it assigned to me, I can work on it this weekend.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the best way I found to handle null values for all fields of type Date and DateTime, feel free to give comments on the approach.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me! Thanks for your work.

@seulsale seulsale closed this Jan 29, 2022
@seulsale seulsale reopened this Feb 2, 2022
@jeremystretch jeremystretch merged commit c0a6279 into netbox-community:develop Feb 14, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Circuit Install Date set to NULL exports to csv as —

2 participants