Another idea: instead of an enum, how about using the datetime.date.year,
month, day attributes?
If you prefer the enum, I don't really see an obvious place for it, so use
your best judgment and make it importable from contrib.admin I suppose.
On Saturday, September 19, 2015 at 12:38:10 AM UTC-4, Gavin Wahl wrote:
>
> Is it going to be possible to get this in before the feature freeze?
>
> On Thursday, September 10, 2015 at 10:21:29 AM UTC-6, Gavin Wahl wrote:
>>
>> The enum seems fine. Where should it be defined? Should the docs mention
>> the integer values at all, or are you required to use the enum?
>>
>> I don't think setting date_hierarchy to a tuple is any cleaner.
>>
>> On Monday, August 31, 2015 at 12:54:21 PM UTC-6, Tim Graham wrote:
>>>
>>> This seems okay at first glance, though I wonder if an enum-like object
>>> might be better than magic int/boolean values. Something like:
>>>
>>> class ApproximateWith(object):
>>> NONE = 0
>>> YEARS = 1
>>> MONTHS = 2
>>> DAYS = 3
>>>
>>> Do you think a separate ModelAdmin attribute better than allowing
>>> something like:
>>>
>>> date_hierarchy = ('pub_date', ApproximateWith.YEARS)
>>>
>>> Values that can be string or tuple have contributed to bugs in the past,
>>> but I thought it might be worth proposing.
>>>
>>> On Saturday, August 29, 2015 at 4:50:20 PM UTC-4, Gavin Wahl wrote:
>>>>
>>>> I'm going to fix ticket #23242 by adding an option to approximate the
>>>> date_hierarchy options instead of calculating them exactly. The
>>>> implementation is straightforward but I'm not sure what the interface
>>>> should be.
>>>>
>>>> The basic idea is instead of doing `SELECT DISTINCT date_trunc('year',
>>>> created_at) FROM table`, then a date_trunc('month', created_at) to get the
>>>> list of months, and so on, you can find the range with `SELECT
>>>> date_trunc('year', max(created_at)), date_trunc('year', min(creeated_at))`
>>>> and just assume that every year/month/day in between is filled in.
>>>>
>>>> How should this feature be enabled? Should it be possible to
>>>> approximate the year list, but once you've selected the year switch to
>>>> exact? I'm thinking something like:
>>>>
>>>> - approximate_date_hierarchy = False # default
>>>> - approximate_date_hierarchy = 1 # approximate years only
>>>> - approximate_date_hierarchy = 2 # approximate months and years
>>>> - approximate_date_hierarchy = 3 or True # approximate days, months,
>>>> and years
>>>>
>>>>
--
You received this message because you are subscribed to the Google Groups
"Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-developers/8361534a-4cc9-48c8-a991-f84bd77a0b98%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.