Trying Django, another Python framework for web developement

django

This entrance is related to Django, a Python framework for web development, and I am learning it from a free Udemy course (in spanish) called Probar Django. This framework is completly different to Flask (the other framework I already wrote about it). Back to Django, you have more information in the offical Django web page.

Creating a virtual environment (virtualenv) in Python

I have no doubt about it, and it is recommend it, but I never do it: create an isolate envorinment for development.

In Python, environments are for isolating systems so you can have several locations where execute different (or modified) versions of Python, limiting the libraries needed for each project.

First to do, is to download virtualenv, using pip:

pip install virtualenv

descargar-virtualenv

downloading-virtualenv

That’s an easy task. Next, you need to create a directory where you will be working, on a different path where you have your Python or Anaconda installation.

Now you are on the working path, let’s create the environment with the instruction:

virtualenv .

crear-virtualenv

create-virtualenv

The process of creating the environment needs some minutes, so once completed, next step is to activate it by using the activate command, that you can find it under scripts:

./scripts/activate

activar-virtualenv

activate-virtualenv

You are in the path, the environment is ready for working with django, so next step is download django, again using pip (you will download last version).

Once you have install django, you can see what’s happening in your path by going to the file explorer:

probar-django

trying-django

There is a script called manage.py that is the core of django, and you can do a lot of things with it:

manage-django

manage-django

Django, up and running

The way of testing that Django is ready to use, is by starting the server with this command:

python manage.py runserver

django-runserver

django-runserver

Now, let’s move to the browser and see what’s happend::

django-welcome

django-welcome

Fantastic, django is up and running. This is the end of this first entrance related to Djando. The main difference at the beginning is that Django comes with several utilities in order to make development easy, while Flask doesn’t. But let’s see more in the next entrance.

happy coding.