1 Django Query by Example (QBE)
2 =============================
4 :synopsis: Admin tool in order to get custom reports.
6 The objective of django-qbe is provide a assited and interactive way of making
7 complex queries with no technical knowledge (or minimal) to get custom reports
8 from the objects of Django models.
10 Based on QBE_ proposal from IBM®, django-qbe is intended to remove the
11 limitations of Django QuerySets objects and to use the whole expresive power of
18 Using the Python Package Index (PyPI_) and easy_install script::
20 $ easy_install django_qbe
24 $ pip install django_qbe
26 But you also can download the *django_qbe* directory using git::
28 $ git clone git://github.com/versae/qbe.git
29 $ cp -r qbe/django_qbe /path/to/your/project
31 Adding to the project settings::
34 # [...] django builtins applications
36 # [...] Any other application
39 And adding the urlconf in your project urls.py::
42 url(r'^qbe/', include('django_qbe.urls')),
44 If you are using Django 1.2 or any previous version you must link or copy the
45 *django_qbe/static/django_qbe* directory in your project media directory::
47 $ ln -s django_qbe/static/django_qbe /path/to/your/project/media/
49 And enable the context processor *django.core.context_processors.media*::
51 TEMPLATE_CONTEXT_PROCESSORS = (
52 # [...] django context processors
53 'django.core.context_processors.media',
54 # [...] Any other context processors
57 But if you're using Django 1.3 or later the static files will be found and served
58 automatically, you don't need to do anything except adding the context processor
59 *django.core.context_processors.static*::
61 TEMPLATE_CONTEXT_PROCESSORS = (
62 # [...] django context processors
63 'django.core.context_processors.static',
64 # [...] Any other context processors
67 See the `Django documentation on static files`__ for details.
71 That's all. Then you can access to http://host:port/qbe
72 However, you can add a link from your admin page changing the admin index
73 template fo your AdminSite::
75 class AdminSite(admin.AdminSite):
76 index_template = "qbe_index.html"
78 Or adding in your custom admin index template the next javascript::
80 <script type="text/javascript" src="{% url qbe_js %}"></script>
86 The next lines show de available settings and its default values.
88 Enable autocompletion tool (work in progress, not enabled yet)::
90 QBE_AUTOCOMPLETE = True
92 Enable an Exhibit faceted navigation for results (not yet implemented)::
96 Admin module name to add admin urls in results::
100 Set your own admin site if it's different to usual *django.contrib.admin.site*::
102 QBE_ADMIN_SITE ="admin.admin_site"
104 Function to control to users with access to QBE::
106 QBE_ACCESS_FOR = lambda user: user.is_staff
108 Path to QBE formats export file, in order to add custom export formats::
110 QBE_FORMATS_EXPORT = "qbe_formats"
113 .. _QBE: http://www.google.com/url?sa=t&source=web&ct=res&cd=2&ved=0CB4QFjAB&url=http%3A%2F%2Fpages.cs.wisc.edu%2F~dbbook%2FopenAccess%2FthirdEdition%2Fqbe.pdf&ei=_UD5S5WSBYP5-Qb-18i8CA&usg=AFQjCNHMv-Pua285zhWT8DevuZFj2gfYKA&sig2=-sTEDWjJhnTaixh2iJfsAw
114 .. _PyPI: http://pypi.python.org/pypi/django_qbe/
115 .. _staticfiles: http://docs.djangoproject.com/en/dev/howto/static-files