SlideShare uma empresa Scribd logo
1 de 14
Baixar para ler offline
Django - Hello World
→ Criando o virtualenv:
Abra o terminal e digite o comando para criar o virtual env
$ virtualenv auladjango --no-site-packages --distribute
auladjango = nome do virtualenv
--no-site-packages = não terá acesso à recursos fora do virtualenv
--distribute = definir a variavel VIRTUALENV_DISTRIBUTE p/ torná-lo padrão.
by Fabiano Góes / Estude[py]
Django - Hello World
→ Ativar o virtualenv
$ cd auladjango/
$ source bin/activate
→ Instalar o Django dentro do virtualenv
$ pip install django
by Fabiano Góes / Estude[py]
Django - Hello World
→ Criar o projeto Django
$ django-admin.py startproject django-hello .
→ Criar a app core
$ cd djangohello/
$ python ../manage.py startapp core
by Fabiano Góes / Estude[py]
← A Estrutura de diretórios
Django - Hello World
→ Executar o projeto
$ python ../manage.py runserver
→ Vizualizar o projeto rodando no browser
by Fabiano Góes / Estude[py]
Django - Hello World
→ Configurar a url home
editar o arquivo urls.py que está dento do diretório /djangohello/urls.py
descomentar a url home e configurar para a view home na app core:
by Fabiano Góes / Estude[py]
Django - Hello World
→ Programar a view home
editar o arquivo views.py que está dento do diretório:
/djangohello/core/views.py
→ Executar o projeto e ver o resultado no browser
$ python ../manage.py runserver
by Fabiano Góes / Estude[py]
Django - Hello World
→ Configurar o Banco de Dados no settings.py
editar o arquivo settings.py que está dento do diretório: /djangohello/settings.py
vamos configurar o ENGINE como sqlite3 e o NAME como database.db
agora vamos instalar a nossa app core e o admin em INSTALLED_APPS
by Fabiano Góes / Estude[py]
Django - Hello World
→ Criando as tabelas do admin
$ python ../manage.py syncdb
by Fabiano Góes / Estude[py]
Django - Hello World
→ Criar nossa primeria classe Model
edite o arquivo djangohello/core/models.py
→ registrar o modelo no admin
crie o arquivo admin.py no diretório /djangohello/core/admin.py
by Fabiano Góes / Estude[py]
Django - Hello World
→ Executar o syncdb para criar a tabela Pessoa
$ python ../manage.py syncdb
→ Configurar a url do admin
edite o arquivo /djangohello/urls.py
by Fabiano Góes / Estude[py]
Django - Hello World
→ Rodar o projeto e executar o admin
$ python ../manage.py runserver
executar o admin no browser na url: http://127.0.0.1:8000/admin/
by Fabiano Góes / Estude[py]
para logar no admin use o
usuário e senha que
foidigitado quando rodamos
o syncdb pela primeira vez:
user: admin
password: admin
Django - Hello World
já podemos ver o nosso modelo Pessoa no admin:
Neste ponto já temos nosso primeiro CRUD feito em django uhuuu 0//
C → Create ( INSERT )
R → Read ( SELECT )
U → Update ( UPDATE )
D → Delete ( DELETE )
by Fabiano Góes / Estude[py]
Django - Hello World
by Fabiano Góes / Estude[py]
Django - Hello World
http://estudepy.wordpress.com/
@fabiano_goes
by Fabiano Góes / Estude[py]

Mais conteúdo relacionado

Destaque

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Destaque (20)

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 

Django - Hello World

  • 1. Django - Hello World → Criando o virtualenv: Abra o terminal e digite o comando para criar o virtual env $ virtualenv auladjango --no-site-packages --distribute auladjango = nome do virtualenv --no-site-packages = não terá acesso à recursos fora do virtualenv --distribute = definir a variavel VIRTUALENV_DISTRIBUTE p/ torná-lo padrão. by Fabiano Góes / Estude[py]
  • 2. Django - Hello World → Ativar o virtualenv $ cd auladjango/ $ source bin/activate → Instalar o Django dentro do virtualenv $ pip install django by Fabiano Góes / Estude[py]
  • 3. Django - Hello World → Criar o projeto Django $ django-admin.py startproject django-hello . → Criar a app core $ cd djangohello/ $ python ../manage.py startapp core by Fabiano Góes / Estude[py] ← A Estrutura de diretórios
  • 4. Django - Hello World → Executar o projeto $ python ../manage.py runserver → Vizualizar o projeto rodando no browser by Fabiano Góes / Estude[py]
  • 5. Django - Hello World → Configurar a url home editar o arquivo urls.py que está dento do diretório /djangohello/urls.py descomentar a url home e configurar para a view home na app core: by Fabiano Góes / Estude[py]
  • 6. Django - Hello World → Programar a view home editar o arquivo views.py que está dento do diretório: /djangohello/core/views.py → Executar o projeto e ver o resultado no browser $ python ../manage.py runserver by Fabiano Góes / Estude[py]
  • 7. Django - Hello World → Configurar o Banco de Dados no settings.py editar o arquivo settings.py que está dento do diretório: /djangohello/settings.py vamos configurar o ENGINE como sqlite3 e o NAME como database.db agora vamos instalar a nossa app core e o admin em INSTALLED_APPS by Fabiano Góes / Estude[py]
  • 8. Django - Hello World → Criando as tabelas do admin $ python ../manage.py syncdb by Fabiano Góes / Estude[py]
  • 9. Django - Hello World → Criar nossa primeria classe Model edite o arquivo djangohello/core/models.py → registrar o modelo no admin crie o arquivo admin.py no diretório /djangohello/core/admin.py by Fabiano Góes / Estude[py]
  • 10. Django - Hello World → Executar o syncdb para criar a tabela Pessoa $ python ../manage.py syncdb → Configurar a url do admin edite o arquivo /djangohello/urls.py by Fabiano Góes / Estude[py]
  • 11. Django - Hello World → Rodar o projeto e executar o admin $ python ../manage.py runserver executar o admin no browser na url: http://127.0.0.1:8000/admin/ by Fabiano Góes / Estude[py] para logar no admin use o usuário e senha que foidigitado quando rodamos o syncdb pela primeira vez: user: admin password: admin
  • 12. Django - Hello World já podemos ver o nosso modelo Pessoa no admin: Neste ponto já temos nosso primeiro CRUD feito em django uhuuu 0// C → Create ( INSERT ) R → Read ( SELECT ) U → Update ( UPDATE ) D → Delete ( DELETE ) by Fabiano Góes / Estude[py]
  • 13. Django - Hello World by Fabiano Góes / Estude[py]
  • 14. Django - Hello World http://estudepy.wordpress.com/ @fabiano_goes by Fabiano Góes / Estude[py]