28
HOW TO CREATE A BASIC WEBSITE WITH PYTHON ON DJANGO

How to create a basic website with Python on Django

Embed Size (px)

Citation preview

Page 1: How to create a basic website with Python on Django

HOW TO CREATE A

BASIC WEBSITE WITH PYTHON

ON DJANGO

Page 2: How to create a basic website with Python on Django

Python?

Page 3: How to create a basic website with Python on Django
Page 4: How to create a basic website with Python on Django

That was a joke!

Page 5: How to create a basic website with Python on Django

Ideology behind name:A television series

Monty Python's Flying Circus

Page 6: How to create a basic website with Python on Django
Page 7: How to create a basic website with Python on Django

Python; Open source Interpreted Interactive

Object Oriented Clear syntax

High-level programming language Batteries included

Page 8: How to create a basic website with Python on Django

Django?

Page 9: How to create a basic website with Python on 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

Page 10: How to create a basic website with Python on Django
Page 11: How to create a basic website with Python on Django

No more spaghetti

code!

Page 12: How to create a basic website with Python on Django

Python (http://python.org/download/)

pip (https://pypi.python.org/pypi/pip)

Page 13: How to create a basic website with Python on Django

Let’s start to work

First; $pip install virtualenv virtualenv devfestwoman Activate virtual environment $pip freeze $pip install Django

Page 14: How to create a basic website with Python on 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

Page 15: How to create a basic website with Python on Django

$python manage.py runserver

Browse http://127.0.0.1:8000

Page 16: How to create a basic website with Python on Django

Now, shoot a glance to devfestwoman/settings.py

Page 17: How to create a basic website with Python on Django

We need to create the tables in the database before we can use them 

$python manage.py syncdb

Page 18: How to create a basic website with Python on Django

Working with applications

$python manage.py startapp core

Page 19: How to create a basic website with Python on Django

Let’s look at what startapp created:

core/__init__.pyadmin.pymodels.pytests.pyviews.py

Page 20: How to create a basic website with Python on Django

Creating models

Page 21: How to create a basic website with Python on Django

add the app to settings.py

$python manage.py syncdb

Page 22: How to create a basic website with Python on Django

Enter the admin site

Browse localhost:8000/admin Register your models on admin.py

Page 23: How to create a basic website with Python on Django

Write the first view declare a URLconf

Write your view

Page 24: How to create a basic website with Python on Django

Showing your data

First, create a directory called templates in your core directory

and write your first template.

Page 25: How to create a basic website with Python on Django
Page 26: How to create a basic website with Python on Django

$python manage.py runserver

Browse http://127.0.0.1:8000

Page 27: How to create a basic website with Python on Django

Thank you for your attendance

Armağan Ersöz

Page 28: How to create a basic website with Python on Django

tşk