Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Workshop Django
Search
Luiz Menezes
February 20, 2016
Programming
2
240
Workshop Django
Oficina de Django apresentada no Opensanca.
Luiz Menezes
February 20, 2016
Tweet
Share
More Decks by Luiz Menezes
See All by Luiz Menezes
async é bom, async eu gosto
luizmenezes
0
42
Processando textos enormes com ferramentas "Unix"
luizmenezes
0
52
Testando aplicações web com py.test e selenium
luizmenezes
0
130
Python 3 Orientado a Objetos
luizmenezes
3
260
Expondo o Raspberry Pi via servidor web
luizmenezes
0
83
Bottle Admin
luizmenezes
0
93
IoT, Raspberry Pi e Python
luizmenezes
1
72
Coding Dojo
luizmenezes
0
52
Other Decks in Programming
See All in Programming
Domain-Driven Transformation
hschwentner
2
1.9k
Djangoアプリケーション 運用のリアル 〜問題発生から可視化、最適化への道〜 #pyconshizu
kashewnuts
1
230
【PHP】破壊的バージョンアップと戦った話〜決断と説得
satoshi256kbyte
0
120
SwiftUI Viewの責務分離
elmetal
PRO
0
140
GitHub Actions × RAGでコードレビューの検証の結果
sho_000
0
240
XStateを用いた堅牢なReact Components設計~複雑なClient Stateをシンプルに~ @React Tokyo ミートアップ #2
kfurusho
1
770
Amazon ECS とマイクロサービスから考えるシステム構成
hiyanger
2
490
CNCF Project の作者が考えている OSS の運営
utam0k
5
690
iOSエンジニアから始める visionOS アプリ開発
nao_randd
3
120
JavaScriptツール群「UnJS」を5分で一気に駆け巡る!
k1tikurisu
10
1.8k
プログラミング言語学習のススメ / why-do-i-learn-programming-language
yashi8484
0
120
技術を根付かせる / How to make technology take root
kubode
1
240
Featured
See All Featured
VelocityConf: Rendering Performance Case Studies
addyosmani
328
24k
Designing for Performance
lara
604
68k
Site-Speed That Sticks
csswizardry
3
370
Six Lessons from altMBA
skipperchong
27
3.6k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.5k
Reflections from 52 weeks, 52 projects
jeffersonlam
348
20k
Building Your Own Lightsaber
phodgson
104
6.2k
Code Review Best Practice
trishagee
66
17k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
129
19k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
29
1k
Transcript
Django Workshop
1. Python
▷ Simples, enxuta e poderosa ▷ Pilhas inclusas ▷ Interpretada
e dinâmica ▷ Comunidade ativa e amigável Python?
▷ Web ◦ Django, Flask, Bottle, Web2py, pyramid, twisted, ...
▷ Programação científica ◦ SciPy, scikit-learn, pandas, NumPy, IPython, matplotlib ▷ Desktop ◦ PyQT, PyGTK, WxPython, tkinter ▷ Cinema ◦ Autodesk Maya, Blender, Nuke, ILM Python: aplicações
▷ InfoSec ◦ Scapy ▷ Internet of Things ◦ MicroPython
▷ Educação ◦ "Python is Now the Most Popular Introductory Teaching Language at Top U.S. Universities" (ACM, 2014) Python: aplicações
▷ IronPython ▷ Jython ▷ PyJS, Brython ▷ PyPy (JIT)
Python: aplicações
PyCon 2015
PyCon 2015
Python Brasil 2014
Python Brasil 2015
2. Django The web framework for perfectionists with deadlines.
▷ Full stack framework ▷ MVT (Model-View-Template) Django
Django: quem usa? ▷ Disqus ▷ Instagram ▷ Mozilla ▷
Pinterest ▷ G1 ▷ Magazine Luiza
3. Instalando Python & Django
Instalando Python 3.5 ▷ Windows: https://www.python.org/downloads/releas e/python-351/
Instalando Python 3.5 ▷ Ubuntu ◦ sudo apt-get install python3.5
▷ Fedora ◦ sudo yum install python3.5 ▷ OS X ◦ https://www.python.org/downloads/rel ease/python-342/
Ambiente virtual (virtualenv) ▷ Para que serve? ◦ É uma
ferramenta que mantem dependências de projetos diferentes em locais separados ◦ Permite trabalhar em um projeto usando o Django 1.9 enquanto mantém um projeto antigo que usa Django 1.5
Ambiente virtual (virtualenv) ▷ Como funciona? ◦ O virtualenv cria
uma pasta com as dependências e executáveis que o projeto python necessita
Ambiente virtual (virtualenv) ▷ Sintaxe de criação do ambiente virtual
(linux) python3 -m venv <nome do env> (win) C:\Python35\python -m venv <nome do env> ▷ Criando o env (linux) python3 -m venv env (win) C:\Python35\python -m venv env
Ambiente virtual (virtualenv) ▷ Ativando o ambiente (linux) source env/bin/activate
(win) env\Scripts\activate ▷ Ao ativar o ambiente deverá aparecer (env) no começo de cada linha do terminal
▷ https://pypi.python.org/pypi ▷ Engloba "todos" os pacotes disponíveis para o
Python PyPI: the Python Package Index
▷ pip serve para instalar pacotes disponíveis no PyPI ▷
pip significa "pip instala pacotes" ▷ Como usar: pip install <nome do pacote> pip: instalando pacotes do PyPI
▷ Instalando o django pip install django e-commerce Projeto Django
e-commerce Projeto Django ▷ Criando o projeto (linux) django-admin startproject
ecom (win) python env\Scripts\django-admin.py starproject ecom ▷ Estrutura ▷ Configurando ◦ Timezone ◦ Arquivos estáticos
▷ Preparando o banco de dados python manage.py migrate ▷
Rodando o projeto python manage.py runserver ▷ Endereço do projeto ◦ http://127.0.0.1:8000/ e-commerce Projeto Django
▷ Criando uma aplicação python manage.py startapp ecommerce ▷ Estrutura
de uma aplicação ▷ Instalando a aplicação e-commerce Aplicação Django
▷ Modelo ◦ User ◦ Produto ◦ Carrinho ◦ Compra
▷ Criando as tabelas ◦ python manage.py makemigrations ecommerce ◦ python manage.py migrate ecommerce e-commerce Modelos
▷ Habilitando o Produto ▷ Página de administração ▷ Superusuário
▷ Cadastro de produtos e-commerce Adminstração
▷ Como funcionam ▷ Regex ◦ ex: http://site.com/usuario/12345 ▷ Criando
ecommerce/urls.py e-commerce URLs
▷ Criando a lista dos produtos ◦ View ◦ Template
HTML ◦ Queryset ◦ Linguagem de template e-commerce Views, Template e ORM
▷ Melhorando a aparência ◦ Template base ◦ Bootstrap http://getbootstrap.com
e-commerce Template
▷ Página do produto ▷ Carrinho de compras ▷ Checkout
(compra) e-commerce Mais funcionalidades
▷ Deploy git & pythonanywhere ◦ http://tutorial.djangogirls.org/pt/deploy/index.html ▷ Autenticação ◦
https://docs.djangoproject.com/en/1.9/topics/auth/ ▷ Customizar o admin ◦ https://docs.djangoproject.com/en/1.9/intro/tutorial 02/#introducing-the-django-admin ◦ melhorar listagem dos produtos ◦ incluir carrinho e-commerce Extra
▷ Materiais ◦ http://tutorial.djangogirls.org/pt/index.html ◦ https://docs.djangoproject.com/en/1.9/intro/tutorial 01/ ◦ http://www.codecademy.com/tracks/web ◦
http://www.codecademy.com/en/tracks/python ◦ https://docs.djangoproject.com/en/1.9/topics/ E depois?
▷ Ainda mais funcionalidades ◦ Autenticação login, logout, cadastro ◦
Perfil do usuário editar dados, listar pedidos ◦ Categorias de produtos ◦ Melhorar ▪ modelos (criar modelos, adicionar campos) ▪ página do produto (exibir mais informações) ▪ compra (descontos, frete, passo-a-passo) ▪ layout (HTML/CSS) e-commerce E depois?
▷ grupy-sanca meetup.com/grupy-sanca ▷ PyLadies São Carlos saocarlos.pyladies.com ▷ Opensanca
opensanca.com.br meetup.com/opensanca E depois?
Obrigado! Dúvidas? Contato: @luiz_amf
[email protected]
Credits Special thanks to all the people who made and
released these awesome resources for free: ▷ Presentation template by SlidesCarnival ▷ How to install python by Django Girls Tutorial