In previous part, we installed Elasticsearch and Kibana. Now we will create a Django project and will link the elastic search with the project.
Django Project:
You can follow the official Django tutorials to create and start a Django project. Or you follow below steps. We will be following the official documentation, but only the necessary steps.
– Make sure python 3 is installed on your machine. Although not mandatory but it is recommended to use virtual environment.
– Install Django. Setup a database. We will be using MySQL.
– Create a project.
$ django-admin startproject elasticsearchdjango
– Change directory to elasticsearch. Create a new app ‘poll’.
$ python manage.py startapp polls
– If you are using virtual environment than install the dependencies using pip install -r req.txt file after saving below lines in req.txt file.
1 2 3 4 5 6 7 8 9 10 11 12 |
certifi==2017.11.5 chardet==3.0.4 Django==1.10.6 elasticsearch==5.5.1 elasticsearch-dsl==5.3.0 idna==2.5 mysqlclient==1.3.10 python-dateutil==2.6.1 pytz==2017.2 requests==2.18.1 six==1.10.0 urllib3==1.21.1 |
– Create a model in polls/models.py file.
1 2 3 4 5 6 7 |
from django.db import models class Question(models.Model): author = models.CharField(max_length=100) question_text = models.CharField(max_length=1000) pub_date = models.DateTimeField('date published') |
Continue reading “Elastic Search with Kibana and Django – part 2”