{ "info": { "author": "Maxime Haineault", "author_email": "haineault@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python" ], "description": "django-pdfutils\n===============\n\nA simple django app to generate PDF documents.\n\n\nInstallation\n------------\n\n1. In your `settings.py`, add `pdfutils` to your `INSTALLED_APPS`.\n2. `(r'^reports/', include(pdfutils.site.urls)),` to your `urls.py`\n3. Add `pdfutils.autodiscover()` to your `urls.py`\n4. Create a `report.py` file in any installed django application.\n5. Create your report(s)\n6. Profit!\n\n**Note**: If you are using buildout, don't forget to put `pdfutils` \nin your `eggs` section or else the django-pdfutils dependencies wont\nbe installed.\n\n\nExample report\n--------------\n\nReports are basically views with custom methods and properties.\n\n.. code-block:: python\n\n # -*- coding: utf-8 -*-\n\n from django.contrib.auth.models import User\n from django.core.urlresolvers import reverse\n from django.utils.translation import ugettext as _\n\n from pdfutils.reports import Report\n from pdfutils.sites import site\n\n\n class MyUserReport(Report):\n title = _('Users')\n template_name = 'myapp/reports/users-report.html'\n slug = 'users-report'\n orientation = 'portrait'\n\n def get_users(self):\n return User.objects.filter(is_staff=True)\n\n def get_styles(self):\n \"\"\"\n It is possible to add or override style like so\n \"\"\"\n self.add_styles('myapp/css/users-report.css')\n return super(AccountStatementReport, self).get_styles()\n\n def filename(self):\n \"\"\"\n The filename can be generated dynamically and translated\n \"\"\"\n return _('Users-report-%(count)s.pdf') % {'count': self.get_users().count() }\n\n def get_context_data(self):\n \"\"\"\n Context data is injected just like a normal view\n \"\"\"\n context = super(AccountStatementReport, self).get_context_data()\n context['user_list'] = self.get_users()\n return context\n\n site.register(MyUserReport)\n\n\nThe slug should obviously be unique since it is used to build the report URL.\n\nFor example, with the default settings and URLs, the URL for report above would be `/reports/users-report/`.\n\nExample template\n----------------\n\n.. code-block:: html\n\n \n
\n {{ STYLES|safe }}\n \n \n