{ "info": { "author": "Patrick Lauber", "author_email": "digi@treepy.com", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python :: 2", "Programming Language :: Python :: 3" ], "description": "# Django Smart Selects\n\n[![Build Status](https://travis-ci.org/digi604/django-smart-selects.svg?branch=master)](https://travis-ci.org/digi604/django-smart-selects)\n\n[![Coverage Status](https://coveralls.io/repos/github/digi604/django-smart-selects/badge.svg?branch=master)](https://coveralls.io/github/digi604/django-smart-selects?branch=master)\n\n# CURRENTLY UNMAINTAINED - Please contact digi604 if you would like to maintain this app #\n\n\nThis package allows you to quickly filter or group \"chained\" models by adding a custom foreign key or many to many field to your models. This will use an AJAX query to load only the applicable chained objects.\n\n**Warning**: The AJAX endpoint enforces no permissions by default. This means that **any model with a chained field will be world readable**. If you would like more control over this permission, the [`django-autocomplete-light`](https://github.com/yourlabs/django-autocomplete-light) package is a great, high-quality package that enables the same functionality with permission checks.\n\n## Chained Selects\n\nGiven the following model:\n\n```python\nclass Continent(models.Model):\n name = models.CharField(max_length=255)\n\nclass Country(models.Model):\n continent = models.ForeignKey(Continent)\n name = models.CharField(max_length=255)\n\nclass Location(models.Model):\n continent = models.ForeignKey(Continent)\n country = models.ForeignKey(Country)\n area = models.ForeignKey(Area)\n city = models.CharField(max_length=50)\n street = models.CharField(max_length=100)\n```\n\nOnce you select a continent, if you want only the countries on that continent to be available, you can use a `ChainedForeignKey` on the `Location` model:\n\n```python\nfrom smart_selects.db_fields import ChainedForeignKey\n\nclass Location(models.Model):\n continent = models.ForeignKey(Continent)\n country = ChainedForeignKey(\n Country,\n chained_field=\"continent\",\n chained_model_field=\"continent\",\n show_all=False,\n auto_choose=True,\n sort=True)\n area = ForeignKey(Area)\n city = models.CharField(max_length=50)\n street = models.CharField(max_length=100)\n```\n\n### ChainedForeignKey options\n\n#### chained_field (required)\n\nThe `chained_field` indicates the field on the same model that should be chained to. In the `Continent`, `Country`, `Location` example, `chained_field` is the name of the field `continent` in model `Location`.\n\n```python\nclass Location(models.Model)\n continent = models.ForeignKey(Continent)\n```\n\n#### chained_model_field (required)\n\nThe `chained_model_field` indicates the field of the chained model that corresponds to the model linked to by the `chained_field`. In the `Continent`, `Country`, `Location` example, `chained_model_field` is the name of field `continent` in Model `Country`.\n\n```python\nclass Country(models.Model):\n continent = models.ForeignKey(Continent)\n```\n\n#### show_all (optional)\n\n`show_all` indicates if only the filtered results should be shown or if you also want to display the other results further down.\n\n#### auto_choose (optional)\n\n`auto_choose` indicates if auto select the choice when there is only one available choice.\n\n#### `sort` (optional)\n\n`sort` indicates if the result set should be sorted lexicographically or not. Disable if you want to use the `Model.ordering` option. Defaults to `True`.\n\n\n## Chained ManyToMany Selects\n\nThe `ChainedManyToManyField` works as you would expect:\n\n```python\nfrom smart_selects.db_fields import ChainedManyToManyField\n\nclass Publication(models.Model):\n name = models.CharField(max_length=255)\n\nclass Writer(models.Model):\n name = models.CharField(max_length=255)\n publications = models.ManyToManyField('Publication', blank=True, null=True)\n\nclass Book(models.Model):\n publication = models.ForeignKey(Publication)\n writer = ChainedManyToManyField(\n Writer,\n chained_field=\"publication\",\n chained_model_field=\"publications\")\n name = models.CharField(max_length=255)\n```\n\n\n### Using chained fields in the admin\n\nDo **not** specify the field in the `ModelAdmin` `filter_horizontal` list. Instead, simply pass `horizontal=True` to the `ChainedManyToManyField`:\n\n```python\nfrom smart_selects.db_fields import ChainedManyToManyField\n\nclass Publication(models.Model):\n name = models.CharField(max_length=255)\n\nclass Writer(models.Model):\n name = models.CharField(max_length=255)\n publications = models.ManyToManyField('Publication', blank=True, null=True)\n\nclass Book(models.Model):\n publication = models.ForeignKey(Publication)\n writer = ChainedManyToManyField(\n Writer,\n horizontal=True,\n verbose_name='writer',\n chained_field=\"publication\",\n chained_model_field=\"publications\")\n name = models.CharField(max_length=255)\n```\n\n\n### ChainedManyToManyField options\n\n#### `chained_field` (required)\n\nThe `chained_field` indicates the field on the same model that should be chained to. In the `Publication`, `Writer`, `Book` example, `chained_field` is the name of the field `publication` in model `Book`.\n\n```python\nclass Book(models.Model):\n publication = models.ForeignKey(Publication)\n```\n\n#### `chained_model_field` (required)\n\nThe `chained_model_field` indicates the field of the chained model that corresponds to the model linked to by the `chained_field`. In the `Publication`, `Writer`, `Book` example, `chained_model_field` is the name of field `publications` in `Writer` model.\n\n```python\nclass Writer(models.Model):\n publications = models.ManyToManyField('Publication', blank=True, null=True)\n```\n\n#### `auto_choose` (optional)\n\n`auto_choose` indicates if auto select the choice when there is only one available choice.\n\n#### `horizontal` (optional)\n\nThis option will mixin Django's `FilteredSelectMultiple` to work in the Django admin as you expect\n\n\n## Grouped Selects\n\nIf you have the following model:\n\n```python\nclass Country(models.Model):\n continent = models.ForeignKey(Continent)\n\nclass Location(models.Model):\n continent = models.ForeignKey(Continent)\n country = models.ForeignKey(Country)\n```\n\nAnd you want to group countries by their continent in the HTML select list, you can use a `GroupedForeignKey`:\n\n```python\nfrom smart_selects.db_fields import GroupedForeignKey\n\nclass Location(models.Model):\n continent = models.ForeignKey(Continent)\n country = GroupedForeignKey(Country, \"continent\")\n```\n\n\n## Installation\n\n1. Add `smart_selects` to your `INSTALLED_APPS`\n2. Add the `smart_selects` urls into your project's `urls.py`. This is needed for the `Chained Selects` and `Chained ManyToMany Selects`. For example:\n\n ```python\n urlpatterns = patterns('',\n url(r'^admin/', include(admin.site.urls)),\n url(r'^chaining/', include('smart_selects.urls')),\n )\n ```\n\n3. You will also need to include jQuery in every page that includes a field from `smart_selects`, or set `JQUERY_URL = True` in your project's `settings.py`.\n\n\n## Settings\n\n`JQUERY_URL`\n: jQuery 2.2.0 is loaded from Google's CDN if this is set to `True`. If you would prefer to\n use a different version put the full URL here. Set `JQUERY_URL = False`\n to disable loading jQuery altogether.\n\n`USE_DJANGO_JQUERY`\n: By default, `smart_selects` loads jQuery from Google's CDN. However, it can use jQuery from Django's\n admin area. Set `USE_DJANGO_JQUERY = True` to enable this behaviour.\n\n\n## TODO\n\n* Add permission checks to enable users to restrict who can use the chained fields.\n* Add a `ChainedCheckboxSelectMultiple` widget and adjust `chainedm2m.js` and `chainedfk.js` to build checkboxes in that case", "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/Murakam1/smart-select-novo", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "django-smart-selects-fix", "package_url": "https://pypi.org/project/django-smart-selects-fix/", "platform": "", "project_url": "https://pypi.org/project/django-smart-selects-fix/", "project_urls": { "Homepage": "https://github.com/Murakam1/smart-select-novo" }, "release_url": "https://pypi.org/project/django-smart-selects-fix/1.0/", "requires_dist": null, "requires_python": "", "summary": "Django application to handle chained model fields.", "version": "1.0" }, "last_serial": 5573674, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "f6a6ce4a5414ee68973f76fa321afdd5", "sha256": "3706390e6fea712b8452bcd98eab02d9c60672353b6d5ef629d1561269052a95" }, "downloads": -1, "filename": "django-smart-selects-fix-1.0.tar.gz", "has_sig": false, "md5_digest": "f6a6ce4a5414ee68973f76fa321afdd5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14316, "upload_time": "2019-07-23T17:50:15", "url": "https://files.pythonhosted.org/packages/13/73/6ff31d351745e079dc6d6d95c16f71a0d95cfb3ae9b3fc6c039ab0b9a2c7/django-smart-selects-fix-1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f6a6ce4a5414ee68973f76fa321afdd5", "sha256": "3706390e6fea712b8452bcd98eab02d9c60672353b6d5ef629d1561269052a95" }, "downloads": -1, "filename": "django-smart-selects-fix-1.0.tar.gz", "has_sig": false, "md5_digest": "f6a6ce4a5414ee68973f76fa321afdd5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14316, "upload_time": "2019-07-23T17:50:15", "url": "https://files.pythonhosted.org/packages/13/73/6ff31d351745e079dc6d6d95c16f71a0d95cfb3ae9b3fc6c039ab0b9a2c7/django-smart-selects-fix-1.0.tar.gz" } ] }