burke-software / django-report-utils Goto Github PK
View Code? Open in Web Editor NEWCommon functions used for reporting needs. Used by django-report-builder and django-report-scaffold.
License: Other
Common functions used for reporting needs. Used by django-report-builder and django-report-scaffold.
License: Other
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])
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
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
response = wrapped_callback(request, _callback_args, *_callback_kwargs)
return self.dispatch(request, _args, *_kwargs)
return bound_func(_args, *_kwargs)
return view_func(request, _args, *_kwargs)
return func.**get**(self, type(self))(_args2, *_kwargs2)
return super(AjaxPreview, self).dispatch(_args, *_kwargs)
return handler(request, _args, *_kwargs)
return self.get(self, request, _args, *_kwargs)
context = self.get_context_data(**kwargs)
preview=True,)
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!
File ".../report_utils/mixins.py", line 278, in report_to_list
if filter_property(property_filter, val):
NameError: global name 'filter_property' is not defined
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....
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:
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
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'):
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.
Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.