how to create a basic website with python on django
TRANSCRIPT
HOW TO CREATE A
BASIC WEBSITE WITH PYTHON
ON DJANGO
Python?
That was a joke!
Ideology behind name:A television series
Monty Python's Flying Circus
Python; Open source Interpreted Interactive
Object Oriented Clear syntax
High-level programming language Batteries included
Django?
High-level Python Web Framework MTV instead of MVC
Built-in ORM (Object –relational Mapper) Simple but powerful URL Patterns
Built-in Authentication System Automatic Admin Interface
No more spaghetti
code!
Python (http://python.org/download/)
pip (https://pypi.python.org/pypi/pip)
Let’s start to work
First; $pip install virtualenv virtualenv devfestwoman Activate virtual environment $pip freeze $pip install Django
Creating a project$django-admin.py startproject devfestwoman
Let’s look at what startproject created:devfestwoman/ manage.py devfestwoman/
__init__.pysettings.pyurls.pywsgi.py
$python manage.py runserver
Browse http://127.0.0.1:8000
Now, shoot a glance to devfestwoman/settings.py
We need to create the tables in the database before we can use them
$python manage.py syncdb
Working with applications
$python manage.py startapp core
Let’s look at what startapp created:
core/__init__.pyadmin.pymodels.pytests.pyviews.py
Creating models
add the app to settings.py
$python manage.py syncdb
Enter the admin site
Browse localhost:8000/admin Register your models on admin.py
Write the first view declare a URLconf
Write your view
Showing your data
First, create a directory called templates in your core directory
and write your first template.
$python manage.py runserver
Browse http://127.0.0.1:8000
Thank you for your attendance
Armağan Ersöz
tşk