没有任何数据可供显示
| 开源项目社区 | 当前位置 : |
|
| www.trustie.net/open_source_projects | 主页 > 开源项目社区 > django-reports |
|
django-reports
|
| 1 | 0 | 3 |
| 贡献者 | 讨论 | 代码提交 |
A django application to build flexible, extensible reports through the web or as part of your views.
This project has been started due to interest on the django-users mailing list and very much subscribes to the "release early and often" philosophy. It is definitely not production ready, but this is an app that I think that users of django could benefit from, especially for those who are interfacing with legacy databases or in some sort of enterprise setting.
The idea is a central register which can easily tell you which fields are available for reports, and allows you to add to define your own reports in a sub-directory of your apps (much like the existing templatetags works). Here's an example from one of my app's report.py:
from nokia.reporting.helpers import FieldRegister
from datetime import timedelta
reg = FieldRegister()
@reg.register('Adjusted MTTR','Ticket','mttr')
def adjusted_mttr(ticket):
"""The mean time to repair of the ticket"""
... rest of code body hereIn addition to the register, there are also a couple of Models (one for holding information on all the available fields, and one for your persistent Report objects) and these between them generate Reporter objects, which can produce CSV.
I'm not convinced that I've taken the right approach in all areas of the application, and I'd very much like feedback and ideas, specifically:
The right way to persist the report objects, their construction is not really consistent and perhaps a relational database structure isn't the best means of storage. I'm thinking that RDF or something similar (XML of some other sort) might be better? Testing... I'm not really familiar with how to go about TDD, but i'd like to learn! User interface, I'm designing this to be brain dead (think dilbert manager ;-) ) simple to use. Presently this UI is dependant on Prototye, and I think this might hinder integrating it into admin views in the future.
Example code:
>>> fld_reg = FieldRegister()
>>> usr = fld_reg.User
>>> #usr now has a representation of all of the fields the auth.User has, uncluding a
>>> #count field for all of the FK and M2M relations and reverse relations:
>>> usr
>
>>> usr._fields #This is all of the User._meta.fields
[,
........
]
>>> usr.message_set
>>> usr.message_set.title
'Count of Message Set'The best way to get to know the app is probably to install it, run syncdb, run generate_fields() (which is in helpers.py), and then have a play using ./manage.py shell. If you're using IPython you'll be up and running in no time.
标签:
