Setting Up Django Development Environment Using Anaconda

Hey there, Happy to see you and welcome to my blog. In this blog series we are gonna learn about Django.  Setting up Django project with Anaconda, an amazing Python web framework for rapid web development.

First of all download Python and Anaconda on your system. Installation is easy just follow the instructions and you will be good to go. Wait a minute, Why we need Anaconda and what the hell is that?

Anaconda is a free and open source distribution of the Python and R that aims to simplify package management and deployment. One can download popular Python and R packages and notebooks to jump start your work.You can also store your packages, notebooks and environments in Anaconda Cloud and share them with your team. So in future if you are gonna work with Machine Learning or Data Science with Python then Anaconda will make your job easier.

Now that you have installed Python and Anaconda on your system. Let’s cross check and see whether or not they are installed. Run command python --version or python -V to check Python and run command conda --version or conda -V or conda info to check Anaconda in your terminal. If you have seen the results as shown in screenshot below. Great, you have done it.

Starting with Django

Now that we have installed Python and Conda. Let’s create project folder and install Django framework . Follow the steps discussed below,

Creating Project Folder

Create a project folder by running command mkdir DjangoDevils1 . The above command will create a project folder with name DjangoDevils1 in your current directory. Get inside your project directory by running command cd DjangoDevils1 . Now try opening your project folder in your favourite IDE or text editor. I recommend two IDEs for any Python project. First one is PyCharm and second one is VS Code. I am gonna use VS Code and if you are following along with me then go to terminal and get inside your project folder then run this command code . , this will open your project folder in VS Code IDE. You are open to use any IDE or text editor that you are comfortable with.

Installing Django Framework with Conda

Now it’s time to install Django framework in your project folder and for this we are gonna rely on Anacoda. Go ahead and run command conda install -c anaconda django in your terminal.

After installing Django you can check the Django version by running command python -m django --version.

Creating Project

Now that you have installed Django framework you are all good to go and create your project. So, for creating project go ahead and run command django-admin startproject DjangoDevils1 in terminal. If above command runs without any error then your project has been created without any error. If you go to your code editor or IDE , you should see your project directory as shown in screenshot below.

Congratulations on installing your very first project in Django. But wait, How to run it? Don’t you worry. I am gonna explain that too. I’ll explain every possible folder and file in upcoming blogs. But for now just focus on manage.py file. This file is a command-line utility that allows you to interact with Django project in various ways.

Running Project on Server

To run the project go to your terminal and get inside you project folder and run command python manage.py runserver.
If command runs successfully, you should get result as shown in screenshot below.

You are getting some texts in red color, don’t worry about them right now. In upcoming blogs we will discuss them. For now go to your browser and run http://127.0.0.1:8000/ or http://localhost:8000/.

You should see Django default page as shown in screenshot below.

Wow! Congratulations again.

Creating virtualenv (Virtual Environment) with Conda

You are able to run your project but till now you have not created virtual environment for project. It’s a nice practice to do that. Let’s do that. Go to your project directory in terminal and run this command  conda create --name DjangoDevils1 python=3.7 .  If you have done that successfully then you should get results as shown below in screenshot .

It gives you two commands, first one as conda activate DjangoDevils1 (DjangoDevils1 is your project name) to activate your virtualenv and second one as conda deactivate to deactivate virtualenv (No need of project name while deactivating virtualenv ).

Video Tutorial for Blog

Conclusion

You learnt about Django and Anaconda. It’s good to be handy with Anaconda as it makes your life easier as a Python geek, whether you are dealing with Machine Learning or Data Science project Anaconda will play a great role. A lot to come in future blogs. Stay tuned. If you have any queries comment down below or you can comment on video tutorial too. I’ll be happy to help.

Prabhat Malhotra

MEAN | MERN | ML | DS | PYTHON | AI | STARTUP | YOUTUBER | BLOGGER | A self motivated and passionate technology enthusiast with learning attitude, who is always excited to grab any kind of risk in career or life. A day with me would be like motivated and discussing over various crazy innovative ideas. Moreover an extrovert and philanthropist who is a die hard fan of coffee too (Ask me for one with crazy ideas and big dreams).

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.