{"_id":"576c1690de333e0e00d0abd7","user":"5633ec9b35355017003ca3f2","__v":8,"version":{"_id":"56be3388be55991700c3ca10","project":"56be3387be55991700c3ca0d","__v":8,"createdAt":"2016-02-12T19:33:28.313Z","releaseDate":"2016-02-12T19:33:28.313Z","categories":["56be3389be55991700c3ca11","57646709b0a8be1900fcd0d8","5764671c89da831700590782","57646d30c176520e00ea8fe5","5764715d4f867c0e002bc8e3","57698fa2e93bfd190028815c","576c2af16c24681700c902da","5787da96b008c91900aae865"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"parentDoc":null,"project":"56be3387be55991700c3ca0d","category":{"_id":"57646d30c176520e00ea8fe5","__v":0,"version":"56be3388be55991700c3ca10","project":"56be3387be55991700c3ca0d","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-06-17T21:35:44.598Z","from_sync":false,"order":0,"slug":"clients","title":"Client Integration"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-06-23T17:04:16.029Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":5,"body":"If your application is using Django, you can use the [Haystack](http://haystacksearch.org/) Solr client. Once you have set up your application as per their official [getting started tutorial](http://django-haystack.readthedocs.org/en/latest/tutorial.html), you should modify your application's `settings.py` to use these settings:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"HAYSTACK_URL      = os.environ.get('WEBSOLR_URL', '')\\nHAYSTACK_CONNECTIONS = {\\n    'default': {\\n        'ENGINE': 'haystack.backends.solr_backend.SolrEngine',\\n        'URL': HAYSTACK_URL,\\n    },\\n}\",\n      \"language\": \"python\",\n      \"name\": \"settings.py\"\n    }\n  ]\n}\n[/block]\nWhen you are ready to deploy to Heroku, use the following command to generate your Solr `schema.xml`, to be uploaded to your Websolr index:\n\n```term\n$ ./manage.py build_solr_schema > schema.xml\n```\n\nCopy the contents of the `schema.xml` file and open the Websolr addon dashboard:\n\n```term\n$ heroku addons:open websolr\n```\n\nSelect your index, and select the \"Advanced\" tab to paste in the contents of your `schema.xml`. Your index will take a minute or two to reconfigure itself, and then you can run the following command to reindex your data:\n\n```term\n$ heroku run python myproject/manage.py rebuild_index\n```","excerpt":"How to integrate the Haystack client for your Django application to use Solr.","slug":"haystack-for-django","type":"basic","title":"Haystack for Django"}

Haystack for Django

How to integrate the Haystack client for your Django application to use Solr.

If your application is using Django, you can use the [Haystack](http://haystacksearch.org/) Solr client. Once you have set up your application as per their official [getting started tutorial](http://django-haystack.readthedocs.org/en/latest/tutorial.html), you should modify your application's `settings.py` to use these settings: [block:code] { "codes": [ { "code": "HAYSTACK_URL = os.environ.get('WEBSOLR_URL', '')\nHAYSTACK_CONNECTIONS = {\n 'default': {\n 'ENGINE': 'haystack.backends.solr_backend.SolrEngine',\n 'URL': HAYSTACK_URL,\n },\n}", "language": "python", "name": "settings.py" } ] } [/block] When you are ready to deploy to Heroku, use the following command to generate your Solr `schema.xml`, to be uploaded to your Websolr index: ```term $ ./manage.py build_solr_schema > schema.xml ``` Copy the contents of the `schema.xml` file and open the Websolr addon dashboard: ```term $ heroku addons:open websolr ``` Select your index, and select the "Advanced" tab to paste in the contents of your `schema.xml`. Your index will take a minute or two to reconfigure itself, and then you can run the following command to reindex your data: ```term $ heroku run python myproject/manage.py rebuild_index ```