Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default value of 'to date' as "current" when empty #163

Open
cccs-ip opened this issue Sep 22, 2014 · 1 comment
Open

default value of 'to date' as "current" when empty #163

cccs-ip opened this issue Sep 22, 2014 · 1 comment
Assignees

Comments

@cccs-ip
Copy link
Member

cccs-ip commented Sep 22, 2014

For the "to date" on projects, we will often leave this field empty where a project is on-going. Could we make it so that the default value is shown as the word 'current' where no data is supplied? Also, could we make it so that an empty value is automatically assumed to be the the current date (for ordering purposes)?

screenshot from 2014-09-21 22 07 19

@pwhipp
Copy link
Contributor

pwhipp commented Sep 23, 2014

I believe the ordering is already correct and this issue is largely subsumed by the discussion in #162.

Anywhere in a template you can use the built in filter 'default_if_none' to display a value thus:
{% obj.to_date|default_if_none:"present" %}

You can chain filters so to format the date you can add the usual date presentation e.g.
{% obj.to_date|default_if_none:"present"|date:"b Y"|title %}
In words, this says "present obj.to_date as 'present' if it is none, as a date formatted as 'b Y', formatted as a title"

@pwhipp pwhipp assigned cccs-ip and unassigned pwhipp Sep 23, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants