Django Hands on

Python into the web


I started with Python last month, just to see what is the fuss about it. I can see how simple it is and that makes it quite powerful, but coming from Ruby and Ruby on Rails, I can see serious resemblance between both of them, and now with Django more of the same. It’s fine, it’s not a critic, not bad feelings, it’s just an observation, if you “jump” from one to another it will not be a “cliff jumping” just a “mud puddle” kind of jump.

Here the steps to have a Django project kicking in no-time. You must have previously python 3 installed ( I followed these steps ). I did in a Windows 10 machine, so this my list of steps. Open a Powershell with Administrator rights and start typing:

# Create directory for your new project
mkdir blog
cd blog

# Create a virtual environment for your project
python -m venv ll_env
# to stop it 

# Install Django
pip install django

# Create the project in Django ATTENTION: Don't forget the . at the end!!!
django-admin startproject blog .

# Creating the database SQLite
python migrate

# Viewing the project 
python runserver

# go to

# Tada!!!!

# Create an App inside your project
# Your virtual environment must be activated
python startapp blogs

You will have to modify in under your project “Blog” to add your app, so it looks like:

..... Snip ..... 
    # My apps
    # Default django apps
..... Snip ..... 
# Let's create a superuser for our admin part
python createsuperuser 
(enter username, and password of your choice, the email is totally optional)

And now you can login in your app as superuser in the admin area :

And now it’s when you start creating models, views, templates, etc.

Ruby & Rails too



I started to develop a new application with Ruby on Rails 6 (RoR). It has been a while since the last time I started a project with a cutting-edge RoR version, so I took the opportunity to dig a little bit about “the good, the bad and the ugly” about RoR and Ruby in general.

Looks like everybody agrees that is not dead, just not a “new toy” like it was 15 years ago, but still in pretty good shape. Some new tricks, but when I started to use it, it looks and feels quite the same, what made me happy. And, I read a lot of mentions about the new coming Ruby 3, looks like Ruby developers are promising in a near future to triplicate the speed which always has been the “but” of this language; we’ll see, we’ll see.

So I created a new Project to have a better opinion about it. I did on a Linux subsystem on Windows 10. There is a great article about how to have it installed in no time in your machine here . It’s fast, don’t add unneeded steps and it works, so why to spend time in telling you the same.

After that just open a bash console, and let’s start typing, first some common prerequisites to have Ruby and Ruby on Rails working.

# Updating everything
sudo apt-get update
# getting some needed packages 
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev 
libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev 
libcurl4-openssl-dev python-software-properties libffi-dev postgresql-
client-common postgresql-client libpq-dev

Now let’s install Ruby with renv.

git clone ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
git clone ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL

Now it will install the latest Ruby version, in my case 2.7.1. (It can take a little while, just be patient)

rbenv install 2.7.1
rbenv global 2.7.1
# checking ruby version
ruby -v

Let’s install Ruby’s package manager, Bundler, it will make your life so easy when installing gems and keeping track of everything installed. Believe me.

gem install bundler
rbenv rehash

Rails is dependent on NodeJS so we will need to have it installed first.

# NodeJS mapped
curl -sL | sudo -E bash -
# installing NodeJS
sudo apt-get install -y nodejs
# checking
nodejs -v

Final step, install Rails:

gem install rails
rbenv rehash
# checking....
rails -v

Done! We did it!!!!

Just in case you want to have PostgreSQL although MySQL works like a charm with Ruby on Rails.

Lets download and install the latest stable version of PostgreSQL Windows binary.

PostgreSQL 9.6.2 provided by BigSQL: Download

After all the installation steps, open a bash terminal and run:

psql -p 5432 -h localhost -U postgres
# to exit the psql console, just type

So these are the minimum steps to have Rails working in your Windows 10 machine under Linux system. Not so many and quite straight forward.