In previous article we learned how to install Elasticsearch and Kibana and connect them together. In second part of the same article we used Elasticsearch in Django project.
Elasticsearch can be used with relational database or non-relational database. In those articles we used relational database MySQL.
In this article we will see how to use MongoDB in Django application.
I use PythonAnyWhere to host Django application quickly. Read here how to host your Django app on PythonAnyWhere for free.
Continue reading “Using MongoDB in Django Application”
In this article we will see how to implement fast text search using elastic search instead of using MySQL or PostgreSQL.
– Ubuntu 16.04
– Python 3.5, Django 1.10
– Elastic Search v6.0.0
– Kibana v6.0.0
As per Wikipedia:
Elasticsearch is a search engine based on Lucene. It provides a distributed, multitenant-capable full-text search engine with an HTTP web interface and schema-free JSON documents.
ElasticSearch indexes documents for your data instead of using data tables like a regular relational database does.
There are two client libraries to interact with ElasticSearch with Python.
In previous part, we installed Elasticsearch and Kibana. Now we will create a Django project and will link the elastic search with the 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
– Create a model in polls/models.py file.
from django.db import models
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”
Until now this is how I use to develop and deploy (update) code on PythonAnyWhere server.
- Make changes in code on my local machine.
- Commit and push the code to remote repository.
- Login to PythonAnyWhere server and start bash terminal.
- Pull the code from remote repository.
- Reload the web app from web tab.
Steps 3 to 5 are time consuming, repetitive and boring. So I thought of eliminating these steps.
In this article we will see how can you get rid of these steps and your web site is automatically updated with the code as soon as you push it to remote repository.
Continue reading “Automatically updating Django website hosted on PythonAnyWhere server with every git push”
In the previous part of article we completed the environment setup to host the Django app on EC2 instance of AWS.
How to setup Django app on EC2 instance (AWS) – Part 1.
Hosting Django Apps on PythonAnyWhere server for free. Step by step guide.
In this article we will start from where we left in last part.
Activate the virtual environment.
python manage.py makemigrations
If you get a message –
No changes detected then make sure migration files from development environment are not present. If still same message is received, mention the name of app with makemigration command.
Continue reading “How to setup Django app on EC2 instance (AWS) – Part 2”
Recently I hosted Django project on EC2 instance of AWS. I find the process very difficult due to multiple reasons which we will see in article.
Hosting on PythonAnyWhere is cake walk as compare to hosting on EC2 instance. And pricing is also almost same.
Since I have gone through the process, I am sharing the step by step approach to host Django application on EC2 instance.
Django - 1.9
Python - 3.x
Ec2 OS - Fedora
Steps to host Django app on EC2:
Create the account and get the .pem file.
Place the file in on your system and change the permission on that file to 644.
chmod 644 aws_key.pem
Login to system from terminal.
ssh -i aws_key.pem email@example.com
Now you are into your home directory. Running
pwd will give you
Continue reading “How to setup Django app on EC2 instance (AWS)”
In this article we will see how to integrate PayUmoney payment gateway in your Django app.
– Register with PayUMoney.Com as seller/merchant. Fill your details in the form and submit.
– Select the product Payment Gateway.
– On the next screen select your Business filing status, Business Name and kind of business. Name of Bank Account Holder should be same as Business Name.
– Similarly complete the next few steps and get your salt and keys.
– You will need to provide your PAN card details, Bank Account Details and Address for account to activate.
– Once above details are provided, you will receive a confirmation call from payumoney and you will require to send the document to them. After that your account will be fully active.
Continue reading “How to integrate PayUMoney payment gateway in Django”
We are starting a series of python scripts which we may use in our daily life to automate mundane task and save some time.
This is the first article in this series. Recently I bought Amazon’s Ebook Reader, kindle paperwhite 3. I purchased few books from kindle store and downloaded most of the books in Epub format. Now kindle doesn’t support epub format. You need to convert them to either mobi or azw3 format.
Continue reading “Python Script 1: Convert ebooks from epub to mobi format”
When I started developing Django applications, one constant concern I had was ‘which is best server for hosting Django applications?’. I read multiple articles about hosting the Django app, hosting service providers and server providing Django support. Most of them provides support for python but very few provide support for django.
I even purchased hosting space on two servers but thanks to money back guarantee scheme, my money was returned as I was not satisfied with their service. Finally I settled for PythonAnyWhere. I liked PythonAnyWhere for its simplicity.
Continue reading “How to upgrade to paid account on PythonAnyWhere”
Sometimes we are required to dump database data in CSV or Excel file. In this article we will see how to download the data in CSV or Excel file in Django.
Continue reading “How to download data as CSV and Excel file in Django”