Coder Social home page Coder Social logo

django-report-utils's People

Contributors

abhiagarwal avatar bufke avatar grantjenks avatar michellejaeg avatar willseward avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-report-utils's Issues

KeyError when choices removed but historic data remains in DB

https://github.com/burke-software/django-report-utils/blob/master/report_utils/mixins.py#L361

If for some reason a choice field's choice gets removed, but there is historic data pointing to that choice, this line throws the following error.

File "/home/ubuntu/web/......./venv/local/lib/python2.7/site-packages/report_utils/mixins.py", line 361, in report_to_list
row[position-1] = unicode(choice_list[row[position-1]])
KeyError: u'NY '

I monkey patched that line with this for now on my install:

try:
    row[position-1] = unicode(choice_list[row[position-1]])
except:
    row[position-1] = unicode(row[position-1])

Export Unicode data to csv: UnicodeEncodeError

Unicode data in fields break the csv export with an UnicodeEncodeError exception (mixins.py line 92, in build_csv_response).

Validated a quick fix, that would require using the unicodecsv drop-in replacement for the standard csv module.

In mixins.py, just replace:
import csv
by
import unicodecsv as csv

Compatibility with django-report-builder 2.7 branch

Hi,

Im trying to use django-report-builder 2.7 branch but when I try to preview the report I created,
I get this error:

AttributeError at /report_builder/ajax_preview/
'DisplayField' object has no attribute 'field_type'

Traceback:
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py" in get_response

  1.                 response = wrapped_callback(request, _callback_args, *_callback_kwargs)
    
    File "/Library/Python/2.7/site-packages/django/views/generic/base.py" in view
  2.         return self.dispatch(request, _args, *_kwargs)
    
    File "/Library/Python/2.7/site-packages/django/utils/decorators.py" in _wrapper
  3.         return bound_func(_args, *_kwargs)
    
    File "/Library/Python/2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
  4.             return view_func(request, _args, *_kwargs)
    
    File "/Library/Python/2.7/site-packages/django/utils/decorators.py" in bound_func
  5.             return func.**get**(self, type(self))(_args2, *_kwargs2)
    
    File "/Library/Python/2.7/site-packages/report_builder/views.py" in dispatch
  6.     return super(AjaxPreview, self).dispatch(_args, *_kwargs)
    
    File "/Library/Python/2.7/site-packages/django/views/generic/base.py" in dispatch
  7.     return handler(request, _args, *_kwargs)
    
    File "/Library/Python/2.7/site-packages/report_builder/views.py" in post
  8.     return self.get(self, request, _args, *_kwargs)
    
    File "/Library/Python/2.7/site-packages/django/views/generic/base.py" in get
  9.     context = self.get_context_data(**kwargs)
    
    File "/Library/Python/2.7/site-packages/report_builder/views.py" in get_context_data
  10.         preview=True,)
    
    File "/Library/Python/2.7/site-packages/report_utils/mixins.py" in report_to_list
  11.         if display_field.field_type == "Invalid":
    

Maybe the django-report-utils package is not compatible with the 2.7 branch of django-report-builder?

Thanks!

Error for proxy models.

When trying to generate reports that include a model that is marked as proxy=True, the api seems to fail.

I found the fix (it all comes to using ContentType.objects.get_for_model with the parameter for_concrete_model set to False, so ContentType for proxy models are also retrieved)

Furthermore, there are other related bugs in model introspection util functions, as fields from proxy models are not retrieved using the meta method get_all_field_names() (get_fields() must be used instead). However this fix might break retro compatibility ...

If you want I can make a pull request....

help with migration problem - django 1.9 - ImportError: cannot import name ReverseManyRelatedObjectsDescriptor

Hello,

Testing out django 1.9, when I run migrations for django-report-utils, I get the following error:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/jonathanmorgan/.virtualenvs/cvnc/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
    utility.execute()
  File "/home/jonathanmorgan/.virtualenvs/cvnc/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 342, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/jonathanmorgan/.virtualenvs/cvnc/local/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/jonathanmorgan/.virtualenvs/cvnc/local/lib/python2.7/site-packages/django/core/management/base.py", line 398, in execute
    self.check()
  File "/home/jonathanmorgan/.virtualenvs/cvnc/local/lib/python2.7/site-packages/django/core/management/base.py", line 426, in check
    include_deployment_checks=include_deployment_checks,
  File "/home/jonathanmorgan/.virtualenvs/cvnc/local/lib/python2.7/site-packages/django/core/checks/registry.py", line 75, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/home/jonathanmorgan/.virtualenvs/cvnc/local/lib/python2.7/site-packages/django/core/checks/urls.py", line 10, in check_url_config
    return check_resolver(resolver)
  File "/home/jonathanmorgan/.virtualenvs/cvnc/local/lib/python2.7/site-packages/django/core/checks/urls.py", line 19, in check_resolver
    for pattern in resolver.url_patterns:
  File "/home/jonathanmorgan/.virtualenvs/cvnc/local/lib/python2.7/site-packages/django/utils/functional.py", line 33, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/jonathanmorgan/.virtualenvs/cvnc/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 417, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/home/jonathanmorgan/.virtualenvs/cvnc/local/lib/python2.7/site-packages/django/utils/functional.py", line 33, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/jonathanmorgan/.virtualenvs/cvnc/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 410, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/jonathanmorgan/Documents/work/cvnc/django-apps/cvnc/cvnc/urls.py", line 29, in <module>
    url( r'^report_builder/', include( 'report_builder.urls' ) ),
  File "/home/jonathanmorgan/.virtualenvs/cvnc/local/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 52, in include
    urlconf_module = import_module(urlconf_module)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/jonathanmorgan/.virtualenvs/cvnc/local/lib/python2.7/site-packages/report_builder/urls.py", line 4, in <module>
    from . import views
  File "/home/jonathanmorgan/.virtualenvs/cvnc/local/lib/python2.7/site-packages/report_builder/views.py", line 18, in <module>
    from report_utils.mixins import DataExportMixin, generate_filename
  File "/home/jonathanmorgan/.virtualenvs/cvnc/local/lib/python2.7/site-packages/report_utils/mixins.py", line 5, in <module>
    from django.db.models.fields.related import ReverseManyRelatedObjectsDescriptor
ImportError: cannot import name ReverseManyRelatedObjectsDescriptor

I read here:

swisscom/cleanerversion#111

that this class is among the ones that have been refactored into a new package:

In django.db.models.fields.related, the members ReverseSingleRelatedObjectDescriptor, ReverseManyRelatedObjectsDescriptor, ManyRelatedObjectsDescriptor, create_many_related_manager, ForeignRelatedObjectsDescriptor have been refactored into new classes at django.db.models.fields.related_descriptors.

I tried updating the mixins.py file so that it references django.db.models.fields.related_descriptors rather than django.db.models.fields.related, but that didn't fix it. So, not sure if that is it or not. I looked in the release notes for 1.9 and didn't see any mention of this...

Any advice on what might be causing this or what I can do to fix it would be greatly appreciated.

Thanks,

Jonathan Morgan

Prepare for Django 1.10

I receive three warnings on the console when using django-report-builder that are related to deprecations coming in Django 1.10, figured I would note these here so we're not surprised when it gets here.

/.../python2.7/site-packages/report_utils/model_introspection.py:41:
RemovedInDjango110Warning: 'get_all_field_names is an unofficial API that has been deprecated. You may be able to replace it with 'get_fields()'
    all_fields_names = model_class._meta.get_all_field_names()

/.../python2.7/site-packages/report_utils/model_introspection.py:43:
RemovedInDjango110Warning: 'get_field_by_name is an unofficial API that has been deprecated. You may be able to replace it with 'get_field()'
    field = model_class._meta.get_field_by_name(field_name)

/.../python2.7/site-packages/report_utils/model_introspection.py:44:
RemovedInDjango110Warning: Usage of field.related has been deprecated. Use field.remote_field instead.
    if field[2] and not field[3] and not hasattr(field[0], 'related'):

get_relation_fields_from_model crashes django admin in certain cases.

In our application use case of report builder (running django 1.8, with report_builder 3.2) anytime a call runs through get_relation_fields_from_model and a related field is found (adding it to relation_fields, line 43) it crashes the admin because line 42 changes state on the actual ManyToOneRel object.

I have a fix for this, it simply involves copying the original object (found in the field[0]) before renaming it. Reports still run, and my admin doesn't crash.

Let me know if this is a verified issue, and if I should submit the PR.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.