{ "info": { "author": "Stephen Mitchell", "author_email": "stephen@echodot.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Programming Language :: Python", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Internet :: WWW/HTTP" ], "description": "Django Datatables\n======\n\nThe django datatables library makes creating tables that make use of the datatables library simple, reusable, pythonic, djangoesque, and quite a bit fun.\n\n**Project Goals**\n\n* Allow creation of tables in a style similar to django forms.\n* Remove tedious editing of datatables javascript config to match columns.\n* Configure ajax URLs automagically.\n* Simplify use of Django style URLs within the datatable\n\n\nInstallation\n------------\n`pip install classy-django-datatables`\n\n\nQuick Setup\n-----\nDownload the library and place it somewhere accessable in your PYTHONPATH. The following is a basic example to demonstrate the ease to get up and running.\n\n**settings.py**\n\nAdd `django_datables` to the `INSTALLED_APPS` setting.\n\n```python\nINSTALLED_APPS = [\n ...\n 'django_datatables',\n ...\n]\n```\n\n**urls.py**\n\nAdd the following line to urls.py.\n\n```python\n url(r'^__django_datatables__/', include('django_datatables.urls')),\n```\n\n**views.py**\n\n```python\n from django_datatables.datatable import *\n from django_datatables import column\n\n class StudyListDatatable(Datatable):\n code_name = column.TextColumn()\n\n class Meta:\n model = Study\n\n def study_list(request)\n datatable = StudyListDatatable()\n return render(request, 'datatables_demo.html',\n {\"datatable\": datatable}\n )\n```\n\n\n**Template**\n\n```python\n {{datatable.render}}\n```\n\nBuilding Up\n-----------\n\n**Custom Title/Value**\n\nIn the example shown, the code_name, as the variable name is automatically used to fetch the field and then used as the header for the column. There will often be cases where the variable name will not coincide to either of these and can be overritten with the following:\n\n```python\n created_date = column.TextColumn(title='Made on')\n scientist = column.TextColumn(value='scientist__scientist_name')\n```\n\n**CSS Class**\n\nA css class to apply to each cell in the column.\n\n```python\n scientist = column.TextColumn(css_class='text-danger')\n```\n\n**Joined tables**\n\nFields in joined tables are accessed using the same syntax used in django.\n\n```python\n scientist = column.TextColumn(value='scientist__scientist_name')\n```\n\n**Adding links**\n\nLinks support django's URL dispatcher. Just add the URL name to the link attribute and the arguments that get passed to the link. You don't even need the column listed -- Django Datables will integentally fetch the needed field and populate the links accordingly.\n\n```python\n code_name = column.TextColumn(link='edit_study', link_args=['slug'])\n```\n\n**Data from multiple fields**\n\nTo pull data from multiple fields into one column, declare the column as a `StringColumn`. If needed, add the fields to be requested from the database in the `Meta.extra_fields` attribute. Finally, render the desired with the render_* method.\n\n```python\n name = column.StringColumn()\n class Meta:\n model = Employee\n extra_fields = ('first_name', 'last_name')\n def render_name(self, row):\n return \"{} {}\".format(row['first_name'], row['last_name']).strip()\n\n\n```\n\nOther Querysets\n---------------\n\nThe initial queryset can be overridden if a more complex query is needed, or if a default filter needs to be in place.\n\n```python\n def get_initial_queryset(self, request):\n return Employee.objects.filter(manager=request.user)\n```\n\nMeta\n----\n\n**model**: the primary model to be displayed in the table\n\n```python\n model = Study\n```\n\n**order_columns**: a list of the columns that can be sorted\n\n```python\n order_columns = ['study_name', 'created_date', 'modified_date', 'scientist']\n```\n\n**initial_order**: the inital sort of the table\n\n```python\n initial_order = ['created_date', 'scientist']\n```\n\n**searching**: (default: `false`) Enable the search box\n\n**search_fields** the fields that the search box will search for content. This can be more finely controlled in the filter_by_search() method.\n\n```python\n search_fields = ['study_name', 'code_name', 'scientist__scientist_name']\n```\n\n**title**: The title of the report. Only used for the filename and sheet name of the excel export.\n\n```python\n title = \"Study List\"\n```\n\n**export_to_excel**: If openpyxl is installed and set to true, will display a link to download an excel file containing all rows in the table.\n\n```python\n export_to_excel = True\n```\n\nCustom rendering\n-------\n\nAny field can have it's render method extended using render_*\n\n```python\n def render_code_name(self, value):\n return value.lower()\n\n def render_created_date(self, value):\n return value.strftime(\"%m/%d/%Y\")\n```\n\n\nColumns\n-------\n\n**Attributes**\n\n* title - Displayed in the header\n* css_class - A CSS class to apply to the column\n* value - The value in the database to use\n* link - The django url name this column will link to\n* link_args - the link arguments\n\nThe following column types are available in the django_datatables.column module.\n\n**TextColumn**: A standard column that will display the contents of a single field.\n\n**ConstantTextColumn(text)**: Will display text independant of the database. Ex: Edit, or Delete\n\n**StringColumn**: A column that will render text using multiple fields. Request the data with `Meta.extra_fields` and format the text with the render_* method.\n\n**CheckBoxColumn**: Render a checkbox.\n\n**GlyphiconColumn(icon)**: Displayan icon from bootstrap's v3 glyphicon set.\n\n**FontAwesome4(icon)**: Display an icon from the Font Awesome 4 library. Ex: `column.FontAwesome4Column('stop-circle fa-2x')`\n(Must manually include bootstrap in source.)\n\n**DateColumn**: Render a date in Y-m-d format.\n\n\nFilters\n-------\nFilter forms can be connected to the datatable by assigning a django form to Meta.filter_form. Naming the fields as django queryset keys (eg: `name__icontains`, `count__gte`) will auto filter the form as needed.\n\n\n### Filter example\n\n```python\n\n\nclass EmployeeFilterForm(forms.Form):\n last_name__icontains = forms.CharField(label=\"Last Name\", required=False)\n\n\nclass StudyListDatatable(datatable.Datatable):\n\n name = column.StringColumn()\n class Meta:\n model = Employee\n filter_form = EmployeeFilterForm\n extra_fields = ('first_name', 'last_name')\n def render_name(self, row):\n return \"{} {}\".format(row['first_name'], row['last_name']).strip()\n\n\n```\n\nIn the template, the form can be displayed with the following. There /must/ be a `.datatable-form` class attached to the form.\n\n```html\n
\n {{datatable.filter_form}}\n \n
\n```\n\n\nPermissions\n-----------\n\nIt's important to not just lock down the view, but also the ajax call that retrieves the data. Fortunately, authentication is easily handled with mixins. Django 1.9 ships with LoginRequiredMixin, UserPassesTestMixin, and PermissionRequiredMixin which handle most use cases. Ensure the permission-related mixins are stated first.\n\nMore information regarding mixins can be found at the official\n[django authentication doc](https://docs.djangoproject.com/en/1.9/topics/auth/default/#the-loginrequired-mixin).\n\n```python\n from django.contrib.auth.mixins import LoginRequiredMixin\n\n class EmployeeListDatatable(LoginRequiredMixin, datatable.Datatable):\n ...\n```\n\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/scuml/django-datatables", "keywords": "", "license": "Apache", "maintainer": "", "maintainer_email": "", "name": "classy-django-datatables", "package_url": "https://pypi.org/project/classy-django-datatables/", "platform": "", "project_url": "https://pypi.org/project/classy-django-datatables/", "project_urls": { "Homepage": "https://github.com/scuml/django-datatables" }, "release_url": "https://pypi.org/project/classy-django-datatables/1.0.8/", "requires_dist": [ "django (>=2)", "pyquerystring" ], "requires_python": ">=3.6", "summary": "Create datatables quickly for django models.", "version": "1.0.8" }, "last_serial": 4194306, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "0fe6effe19dc716b8d6d1b4ce90acc57", "sha256": "1aba8d3abc6b23b92b26e7ec3d5463de372b933faef0d5a333c4cfe4a25b75b5" }, "downloads": -1, "filename": "classy_django_datatables-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "0fe6effe19dc716b8d6d1b4ce90acc57", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 8466, "upload_time": "2018-08-17T20:12:57", "url": "https://files.pythonhosted.org/packages/5e/37/f77f851705e91921743ab590d045ffc9d323929e015ba9fe39169935c89e/classy_django_datatables-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a5d22c22daa8a93625aaf1c3dc86bb7d", "sha256": "ec47c919b3072e67ef37760ef32b251c04f55cbc06864775ac5fa00f2c6faadc" }, "downloads": -1, "filename": "classy-django-datatables-1.0.0.tar.gz", "has_sig": false, "md5_digest": "a5d22c22daa8a93625aaf1c3dc86bb7d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7496, "upload_time": "2018-08-17T20:12:56", "url": "https://files.pythonhosted.org/packages/67/b9/0dae4355a73233e84c5f4786f82fd96398f0555ada45a4339f0b0717ebc6/classy-django-datatables-1.0.0.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "44c167264a04292fc4ccf8645fc0a888", "sha256": "030b8da2ba842090af63cbf9b56e268cc086bbc4f252ec26102ce56ce8b3fa02" }, "downloads": -1, "filename": "classy_django_datatables-1.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "44c167264a04292fc4ccf8645fc0a888", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 11432, "upload_time": "2018-08-20T20:53:58", "url": "https://files.pythonhosted.org/packages/d8/29/0cfac89b245241e85322ee37a85d33fd05c2d96882f1cb42a88c2587aabe/classy_django_datatables-1.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5df962b0ca3d9a642efa5bea0147db03", "sha256": "8dadd20cd5d099a93bd6619f73e7fd193eca8b3c7cd14da0dc6a186f4756952e" }, "downloads": -1, "filename": "classy-django-datatables-1.0.2.tar.gz", "has_sig": false, "md5_digest": "5df962b0ca3d9a642efa5bea0147db03", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11609, "upload_time": "2018-08-20T20:53:57", "url": "https://files.pythonhosted.org/packages/b8/6e/6fd195b5e8f7691c4c201daa8899120678c709fd4d2898f322cbadb468fc/classy-django-datatables-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "5efc8d4240beb428005ad71df6ff7b99", "sha256": "8bdda160afa7bfcc28711dfb26efc147ca2dbc9b842f238466ce93c42b78a50b" }, "downloads": -1, "filename": "classy_django_datatables-1.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "5efc8d4240beb428005ad71df6ff7b99", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 11553, "upload_time": "2018-08-20T21:49:35", "url": "https://files.pythonhosted.org/packages/a2/ee/18cc6958808a481b66d8fc7391127393fcb749e196d4632421f4b6e4d23d/classy_django_datatables-1.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f1780839d413aeed63776e1c3f448c97", "sha256": "ccdc96d828e62a0227b06cd16b3933c810c79054b06abee9c60042b48689d5de" }, "downloads": -1, "filename": "classy-django-datatables-1.0.3.tar.gz", "has_sig": false, "md5_digest": "f1780839d413aeed63776e1c3f448c97", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11459, "upload_time": "2018-08-20T21:49:33", "url": "https://files.pythonhosted.org/packages/bc/34/e25ddd15a5e26c7e3dc08e3261900510c0c915c66cc9afc75f39164965fb/classy-django-datatables-1.0.3.tar.gz" } ], "1.0.4": [ { "comment_text": "", "digests": { "md5": "35dfe3fb27180e57319f13787449da8b", "sha256": "2e1a5699ef57616a5e683f7aa70b2dd677acf26b654ce25bf7612e279a011192" }, "downloads": -1, "filename": "classy_django_datatables-1.0.4-py3-none-any.whl", "has_sig": false, "md5_digest": "35dfe3fb27180e57319f13787449da8b", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 11555, "upload_time": "2018-08-21T13:29:21", "url": "https://files.pythonhosted.org/packages/ed/13/fe06f68d43513535c41352adb3df31858c15f8d13455db28679fac540eae/classy_django_datatables-1.0.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "83a8eb5fb4f841039c491c2e288c8352", "sha256": "324c97ebbe1032e59302832ed51aab4452882bef558cf0885ee54a8c215350b2" }, "downloads": -1, "filename": "classy-django-datatables-1.0.4.tar.gz", "has_sig": false, "md5_digest": "83a8eb5fb4f841039c491c2e288c8352", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11477, "upload_time": "2018-08-21T13:29:19", "url": "https://files.pythonhosted.org/packages/74/f0/a4bd56333322e624896cf89dc0ed66452fddbf064b735ebf5946c68e671c/classy-django-datatables-1.0.4.tar.gz" } ], "1.0.6": [ { "comment_text": "", "digests": { "md5": "bf4edd9993a15afe2b9f9f2dd6f1e7c1", "sha256": "192a3bdb398ace9079eddab2e190f9b28b9c21bbb3f6778e19c130d00fd5fd29" }, "downloads": -1, "filename": "classy_django_datatables-1.0.6-py3-none-any.whl", "has_sig": false, "md5_digest": "bf4edd9993a15afe2b9f9f2dd6f1e7c1", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 14178, "upload_time": "2018-08-21T14:07:07", "url": "https://files.pythonhosted.org/packages/67/30/a0a9846919382f0ac3b5db791dfd9416145c76265063569c3ae5b170955c/classy_django_datatables-1.0.6-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "cfa7aec2ca5d41541cf6bafc37ee14ef", "sha256": "26765c0df8b489ba2e13e6f19c44c03a04b4be9105ce63bbb19fab77d975e81d" }, "downloads": -1, "filename": "classy-django-datatables-1.0.6.tar.gz", "has_sig": false, "md5_digest": "cfa7aec2ca5d41541cf6bafc37ee14ef", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12275, "upload_time": "2018-08-21T14:07:06", "url": "https://files.pythonhosted.org/packages/3f/3e/079a55ae7d9ad28f397d6a3a73df4cebba2f719e7b2444376153807cd8b7/classy-django-datatables-1.0.6.tar.gz" } ], "1.0.7": [ { "comment_text": "", "digests": { "md5": "7e7c7b3591877803182f3d11183dcf67", "sha256": "843f02fbc902f4421bc7377cc07e247fdbd6eb95f0b567f1a033a61982554cb1" }, "downloads": -1, "filename": "classy_django_datatables-1.0.7-py3-none-any.whl", "has_sig": false, "md5_digest": "7e7c7b3591877803182f3d11183dcf67", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 15873, "upload_time": "2018-08-21T22:21:10", "url": "https://files.pythonhosted.org/packages/2e/26/3c19adb649e31c05959cded3063870172d6699bcc816604fd4290f45d7de/classy_django_datatables-1.0.7-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7464f59249ad98570916dbce8bf4493b", "sha256": "814837a8e7a96ab97f8f1dd2f5f16ab59e4c4356503b1cede926d4da4d012cfe" }, "downloads": -1, "filename": "classy-django-datatables-1.0.7.tar.gz", "has_sig": false, "md5_digest": "7464f59249ad98570916dbce8bf4493b", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 13852, "upload_time": "2018-08-21T22:21:11", "url": "https://files.pythonhosted.org/packages/33/a1/060254ebf83ee394659212deca3916c66eaf3584320b391998366954ca3b/classy-django-datatables-1.0.7.tar.gz" } ], "1.0.8": [ { "comment_text": "", "digests": { "md5": "ed803c7d126ad3e8bc3aa822c0c87125", "sha256": "d4b06a91ced46deb4b55295c649c6ffec1fec14ccc29e1f618bdf34d950b1967" }, "downloads": -1, "filename": "classy_django_datatables-1.0.8-py3-none-any.whl", "has_sig": false, "md5_digest": "ed803c7d126ad3e8bc3aa822c0c87125", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 15849, "upload_time": "2018-08-21T22:47:20", "url": "https://files.pythonhosted.org/packages/1f/7a/21663a6d50533e437ab2b0d993d1b5d1c6353d634d495a81df6d0dfa810d/classy_django_datatables-1.0.8-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "cefba9674a554578df54a115ccb59cf5", "sha256": "cc9a12b61eb577da3f457b985ed7af6d9ea21735308f569c200dbe40749761f7" }, "downloads": -1, "filename": "classy-django-datatables-1.0.8.tar.gz", "has_sig": false, "md5_digest": "cefba9674a554578df54a115ccb59cf5", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 13934, "upload_time": "2018-08-21T22:47:22", "url": "https://files.pythonhosted.org/packages/c8/73/794a3fd8c9f02f79abf0d1c362849797c884752b5f5f8204b36508f2e208/classy-django-datatables-1.0.8.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ed803c7d126ad3e8bc3aa822c0c87125", "sha256": "d4b06a91ced46deb4b55295c649c6ffec1fec14ccc29e1f618bdf34d950b1967" }, "downloads": -1, "filename": "classy_django_datatables-1.0.8-py3-none-any.whl", "has_sig": false, "md5_digest": "ed803c7d126ad3e8bc3aa822c0c87125", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 15849, "upload_time": "2018-08-21T22:47:20", "url": "https://files.pythonhosted.org/packages/1f/7a/21663a6d50533e437ab2b0d993d1b5d1c6353d634d495a81df6d0dfa810d/classy_django_datatables-1.0.8-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "cefba9674a554578df54a115ccb59cf5", "sha256": "cc9a12b61eb577da3f457b985ed7af6d9ea21735308f569c200dbe40749761f7" }, "downloads": -1, "filename": "classy-django-datatables-1.0.8.tar.gz", "has_sig": false, "md5_digest": "cefba9674a554578df54a115ccb59cf5", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 13934, "upload_time": "2018-08-21T22:47:22", "url": "https://files.pythonhosted.org/packages/c8/73/794a3fd8c9f02f79abf0d1c362849797c884752b5f5f8204b36508f2e208/classy-django-datatables-1.0.8.tar.gz" } ] }