Web Applications using Python and Django

Install Python and Django

Create the Base Django Web Application

├── manage.py
└── webapp
├── __init__.py
├── settings.py
├── urls.py
└── wsgi.py

Project Management: manage.py

[auth]
changepassword
createsuperuser
[contenttypes]
remove_stale_contenttypes
[django]
check
compilemessages
createcachetable
dbshell
diffsettings
dumpdata
flush
inspectdb
loaddata
makemessages
makemigrations
migrate
sendtestemail
shell
showmigrations
sqlflush
sqlmigrate
sqlsequencereset
squashmigrations
startapp
startproject
test
testserver
[sessions]
clearsessions
[staticfiles]
collectstatic
findstatic
runserver

Run the application for the first time

Performing system checks...System check identified no issues (0 silenced).You have 15 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
November 05, 2018 - 22:27:59
Django version 2.1.3, using settings 'webapp.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
The default Django page
The default Django page

Creating the default tables for authentication

Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying admin.0003_logentry_add_action_flag_choices... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying auth.0008_alter_user_username_max_length... OK
Applying auth.0009_alter_user_last_name_max_length... OK
Applying sessions.0001_initial... OK
Resultado de imagen para django admin web
Resultado de imagen para django admin web

Creating the Administrator User (Superuser)

Username (leave blank to use 'user'): admin
Email address: admin@gmail.com
Password:
Password (again):
Superuser created successfully.

Creating an App inside your project

> example
> webapp
- manage.py
example/
├── __init__.py
├── admin.py
├── apps.py
├── migrations/
│ └── __init__.py
├── models.py
├── tests.py
└── views.py

Creating Views

Create a View

from django.shortcuts import render
from
django.http import HttpResponse
def index(request):
return HttpResponse("<h1>Hello World</h1>")
from example import viewsurlpatterns = [
path('admin/', admin.site.urls),
path('', views.index)
]

Hello World

The settings.py file

Conclusion

Example Project

Programming from the past century. Worked with many programming languages and software development tools for desktop, web and mobile. https://fraigo.github.io/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store