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”
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”
Using Google reCAPTCHA in Django forms is one of the best way to prevent login attack in your Django application. Although you may deploy other measures like blocking user after 3 unsuccessful attempts or blocking the IP address but I think reCAPTCHA is one of the most widely used method to stop bots from attacking your login/sign-in page.
In this article we will see how to use Google reCAPTCHA in Django forms.
Continue reading “How to use Google reCAPTCHA in Django”
Consider these scenario in your newly developed Django Application:
- You need to send promotional emails to all the registered users.
- You need to send email confirmation link or password reset link.
- You need to send weekly newsletter to you readers.
What do you choose? Free Gmail Account to send email using python code? That is a nice idea provided you want to look unprofessional and you need not to send more than 500 emails per day.
But if you want professional look in your emails [from address something like
firstname.lastname@example.org instead of
email@example.com and do not want the limit on per day email count, then this article is for you.
Continue reading “How to send bulk emails for free using Mailgun and Python Django”
At some point in your project development process you will need AJAX to execute some task. One fine example could be checking username availability on signup form. We will discuss same scenario here and will guide you through the step by step process of using AJAX with Django.
Continue reading “How to use AJAX with Django”
You must have used createsuperuser command in your django application at one or other time. If not then I am sure you must have used makemigrations or migrate commands in your project. Yes? Yes.
So these commands, also called as management commands are used to execute some piece of code from command line. In this article I will tell you how to create your own command.
Why do you need management command:
First thing that comes to your mind after reading above paragraph is that why do even I need management command in my project.
Lets say you have a project where you need to perform some task periodically. For example : updating database column after fetching data from some other server, sending lots of mails, taking backup of your database etc etc.
Continue reading “How to create management commands in Django”
Update 1: Please refer this updated article for Django 2.0 and source code.
It happens very frequently that a visitor on your website typed a wrong URL or the page user is looking for no longer exists. What do you do to handle such cases.
You have three options.
- Redirect the visitor to home page, silently.
- Show a boring 404 page and then ask them to click on a link.
- Create your own funny/awesome/informative custom 404 error page.
In this article we will discuss the third option.
Continue reading “Designing custom 404 and 500 error pages in Django”
To send email using python script via Office 365, use below code. This code is tried and tested.
Continue reading “How to send email from Python and Django using Office 365”
In this article we will discuss how to upload a csv file and then process the content without storing file on server. One approach could be uploading the file, storing it in upload directory and then reading the file. Another approach could be uploading file and reading it directly from post data without storing it in memory and displaying the data.
We will work with the later approach here.
Continue reading “How to upload and process the CSV file in Django”