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

NotImplementedError when using date_hierarchy #73

Open
GordonFreemem opened this issue Nov 5, 2014 · 3 comments
Open

NotImplementedError when using date_hierarchy #73

GordonFreemem opened this issue Nov 5, 2014 · 3 comments

Comments

@GordonFreemem
Copy link

Hi,

when I'm using the date_hierarchy option to filter the change_list admin page for a model, the db-backend raises a NotImplementedError.

Request Method: GET
Request URL: http://:/admin///
Django Version: 1.6
Exception Type: NotImplementedError
Exception Location: //lib/python2.7/site-packages/django/db/backends/init.py in datetime_extract_sql, line 755
Python Executable: /usr/bin/python
Python Version: 2.7.5

admin.py:
class MyModelAdmin(admin.ModelAdmin):
list_display = [ "", "", "date" ]
list_filter = [ "date" ]
date_hierarchy = "date"
ordering = [ "-date" ]

admin.site.register(MyModel, MyModelAdmin)

Environment:
Django==1.6
django-pyodbc==0.2.5
pyodbc==3.0.7

settings.py:
DATABASES = {
'default': {
'ENGINE': 'django_pyodbc',
'USER': '<django_user>',
'PASSWORD': '',
'NAME': '<django_test>',
'OPTIONS': {
'dsn': '',
'encoding': 'utf-8',
'autocommit': True,
}
}
}

When removing the line "date_hierarchy = "date"" everything works as expected.

@matijakolaric
Copy link

Its related to the fact that dates are not converted to datetime.date,
but remain unicode.

On 05.11.2014 16:33, Gordon Schultz wrote:

Hi,

when I'm using the date_hierarchy option to filter the change_list
admin page for a model, the db-backend raises a NotImplementedError.

Request Method: GET
Request URL: http://:/admin///
Django Version: 1.6
Exception Type: NotImplementedError
Exception Location:
//lib/python2.7/site-packages/django/db/backends/init.py in
datetime_extract_sql, line 755
Python Executable: /usr/bin/python
Python Version: 2.7.5

admin.py:
class MyModelAdmin(admin.ModelAdmin):
list_display = [ "", "", "date" ]
list_filter = [ "date" ]
date_hierarchy = "date"
ordering = [ "-date" ]

admin.site.register(MyModel, MyModelAdmin)

Environment:
Django==1.6
django-pyodbc==0.2.5
pyodbc==3.0.7

settings.py:
DATABASES = {
'default': {
'ENGINE': 'django_pyodbc',
'USER': '',
'PASSWORD': '',
'NAME': '',
'OPTIONS': {
'dsn': '',
'encoding': 'utf-8',
'autocommit': True,
}
}
}

When removing the line "date_hierarchy = "date"" everything works as
expected.


Reply to this email directly or view it on GitHub
#73.

@GordonFreemem
Copy link
Author

So this feature is not usable with sqlserver?

@matijakolaric
Copy link

No.
I have been going arounf the problem so far by using haks like:

    def extraInitForPeriod(*args, **kwargs):
        obj = kwargs.get('instance')
        if obj and obj.start_date:
            if isinstance(obj.start_date, basestring):
                obj.start_date = datetime.strptime(
                    obj.start_date, '%Y-%m-%d').date()

But for date_herarchy a proper fix would be needed.

@dlo dlo added the help wanted label Feb 1, 2018
@dlo dlo added the bug label Mar 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants