Install Django on Ubuntu 16.04

Ref: https://tecadmin.net/install-django-on-ubuntu/

Check python3 (no need python2) version and pip3 version

I need to upgrade pip with this command (must with sudo)

but when I checked the newest installed pip, I got this

SOLUTION: https://askubuntu.com/questions/1034018/problem-in-installing-pip-in-ubuntu-16-04
So I need to do this after the upgrade:

Install Django (NO) — USE VIRTUALENV INSTEAD (http://myprojects.advchaweb.com/index.php/2018/01/24/ubuntu-16-04-3-installation-problem-and-solution/)

USE VIRTUALENV

Go to ‘djangotest’ directory and run migration if exist

RUN SERVER

OPEN IT ON YOUR BROWSER: http://localhost:8000/
LOGIN ADMIN
http://localhost:8000/admin/login/?next=/admin/CREATE SUPERUSER FOR ADMIN

so superuser:
username: admin
password: admin123

THEN LOGIN TO ADMIN AGAIN WITH THIS SUPERUSER ACCOUNT. HERE IS THE ADMIN DASHBOARDDEACTIVATE

 

INSTALL NEWEST DJANGO (VERSION 2.2) WITH VIRTUALENV ‘django2.2’

CHECK THE DJANGO VERSION

CREATE DJANGO APP PROJECT ‘django_app’

Goto the project directory and migrate

CREATE SUPERUSER ACCOUNT

so superuser:
username: admin
password: admin123

RUN DJANGO SERVER

OPEN: http://localhost:8000/THE ADMIN (http://localhost:8000/admin/) HAS SAME ACCOUNT AND DISPLAY

CREATE POLLS APP
ref: https://docs.djangoproject.com/en/2.2/intro/tutorial01/
Go to the ‘django_app’ directory:

activate the virtualenv ‘django2.2’ then go to the project directory

create ‘polls’ app

That’ll create a directory polls, which is laid out like this:

Write your first view
Let’s write the first view. Open the file polls/views.py and put the following Python code in it:

This is the simplest view possible in Django. To call the view, we need to map it to a URL – and for this we need a URLconf.

To create a URLconf in the polls directory, create a file called urls.py. Then Open the file polls/urls.py

The next step is to point the root URLconf at the polls.urls module. In django_app/urls.py, add an import for django.urls.include and insert an include() in the urlpatterns list, so you have:

Then run the server

open: http://localhost:8000/polls/
NOTE: BUT I GOT AN ERROR IF I OPEN http://localhost:8000/