{"id":283,"date":"2024-04-01T14:12:30","date_gmt":"2024-04-01T17:12:30","guid":{"rendered":"https:\/\/difusao.tech\/blog\/?p=283"},"modified":"2024-04-01T15:36:29","modified_gmt":"2024-04-01T18:36:29","slug":"hello-world-em-python-usando-django","status":"publish","type":"post","link":"https:\/\/difusao.tech\/blog\/hello-world-em-python-usando-django\/","title":{"rendered":"Hello world em Python usando Django"},"content":{"rendered":"<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" src=\"https:\/\/difusao.tech\/blog\/wp-content\/uploads\/2024\/04\/django.png\" alt=\"\" class=\"wp-image-288\" style=\"width:452px;height:auto\"\/><\/figure>\n<\/div>\n\n\n<p>Antes de come\u00e7ar vale lembrar que n\u00e3o vou abordar a cria\u00e7\u00e3o de ambiente para n\u00e3o alongar muito o post, podemos falar sobre isso em uma pr\u00f3xima oportunidade.<\/p>\n\n\n\n<p>Primeir vamos realizar a instala\u00e7\u00e3o do Django.<\/p>\n\n\n\n<p>Vamos tirar como base que j\u00e1 temos o python instalado, caso esteja na d\u00favida digite <mark style=\"background-color:#abb8c3\" class=\"has-inline-color\">python &#8211;version<\/mark> no PowerShell.<\/p>\n\n\n\n<p>Ainda no PowerShell realize a instala\u00e7\u00e3o do Django com o comando:<\/p>\n\n\n\n<p><mark style=\"background-color:#abb8c3\" class=\"has-inline-color\">pip install django<\/mark><\/p>\n\n\n\n<p>ou<\/p>\n\n\n\n<p><mark style=\"background-color:#abb8c3\" class=\"has-inline-color\">py -m pip install django<\/mark><\/p>\n\n\n\n<p>Ap\u00f3s a instala\u00e7\u00e3o vamos conferir com o comando:<\/p>\n\n\n\n<p><mark style=\"background-color:#abb8c3\" class=\"has-inline-color\">django-admin &#8211;version<\/mark><\/p>\n\n\n\n<p>Segue print de como estamos at\u00e9 agora.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"606\" height=\"340\" src=\"https:\/\/difusao.tech\/blog\/wp-content\/uploads\/2024\/04\/image.png\" alt=\"\" class=\"wp-image-284\" srcset=\"https:\/\/difusao.tech\/blog\/wp-content\/uploads\/2024\/04\/image.png 606w, https:\/\/difusao.tech\/blog\/wp-content\/uploads\/2024\/04\/image-300x168.png 300w\" sizes=\"auto, (max-width: 606px) 100vw, 606px\" \/><\/figure>\n\n\n\n<p>Agora abra o VS Code na pasta a qual deseja que fique o seu projeto e execute o comando a seguir para cria\u00e7\u00e3o do projeto:<\/p>\n\n\n\n<p>obs.: Para abrir o PowerShell no VS Code digite <mark style=\"background-color:#abb8c3\" class=\"has-inline-color\">control + j<\/mark><\/p>\n\n\n\n<p><mark style=\"background-color:#abb8c3\" class=\"has-inline-color\">django-admin startproject hello<\/mark><\/p>\n\n\n\n<p>Onde hello \u00e9 o nome do projeto, ele vai crirar algumas pastas e arquivos do seu projeto.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"785\" height=\"592\" src=\"https:\/\/difusao.tech\/blog\/wp-content\/uploads\/2024\/04\/image-1.png\" alt=\"\" class=\"wp-image-285\" srcset=\"https:\/\/difusao.tech\/blog\/wp-content\/uploads\/2024\/04\/image-1.png 785w, https:\/\/difusao.tech\/blog\/wp-content\/uploads\/2024\/04\/image-1-300x226.png 300w, https:\/\/difusao.tech\/blog\/wp-content\/uploads\/2024\/04\/image-1-768x579.png 768w\" sizes=\"auto, (max-width: 785px) 100vw, 785px\" \/><\/figure>\n\n\n\n<p>Em seguida vamos entrar na pasta do projeto com o comando:<\/p>\n\n\n\n<p><mark style=\"background-color:#abb8c3\" class=\"has-inline-color\">cd hello<\/mark><\/p>\n\n\n\n<p>Onde hello \u00e9 o nome da pasta que foi criado ao criar o projeto, e em seguida digitar o comando para rodar o projeto:<\/p>\n\n\n\n<p><mark style=\"background-color:#abb8c3\" class=\"has-inline-color\">py manage.py runserver<\/mark><\/p>\n\n\n\n<p>Agora o projeto esta rodando no localhost na porta 8000 como mostrado abaixo:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"895\" height=\"299\" src=\"https:\/\/difusao.tech\/blog\/wp-content\/uploads\/2024\/04\/image-2.png\" alt=\"\" class=\"wp-image-286\" srcset=\"https:\/\/difusao.tech\/blog\/wp-content\/uploads\/2024\/04\/image-2.png 895w, https:\/\/difusao.tech\/blog\/wp-content\/uploads\/2024\/04\/image-2-300x100.png 300w, https:\/\/difusao.tech\/blog\/wp-content\/uploads\/2024\/04\/image-2-768x257.png 768w\" sizes=\"auto, (max-width: 895px) 100vw, 895px\" \/><\/figure>\n\n\n\n<p>Entre no navegador e digite 127.0.0.1:8000<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"470\" src=\"https:\/\/difusao.tech\/blog\/wp-content\/uploads\/2024\/04\/image-3-1024x470.png\" alt=\"\" class=\"wp-image-287\" srcset=\"https:\/\/difusao.tech\/blog\/wp-content\/uploads\/2024\/04\/image-3-1024x470.png 1024w, https:\/\/difusao.tech\/blog\/wp-content\/uploads\/2024\/04\/image-3-300x138.png 300w, https:\/\/difusao.tech\/blog\/wp-content\/uploads\/2024\/04\/image-3-768x353.png 768w, https:\/\/difusao.tech\/blog\/wp-content\/uploads\/2024\/04\/image-3.png 1067w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Temos o nossa p\u00e1gina de boas vindas do Django, o que equivale ao nosso Hello World para Django.<\/p>\n\n\n\n<p>Para n\u00e3o ficar apenas nisso, vamos continuar e elaborar um pouco mais o nosso projeto no pr\u00f3ximo post, segue o link:<\/p>\n\n\n\n<p class=\"has-text-align-center\"><a href=\"https:\/\/difusao.tech\/blog\/index.php\/2024\/04\/01\/criando-um-sistema-de-cadastro-com-django-parte-1\/\">Criando um sistema de cadastro com Django.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Antes de come\u00e7ar vale lembrar que n\u00e3o vou abordar a cria\u00e7\u00e3o de ambiente para n\u00e3o alongar muito o<\/p>\n","protected":false},"author":1,"featured_media":292,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30,157],"tags":[222,223,224,158],"class_list":["post-283","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programacao-e-desenvolvimento","category-python","tag-django","tag-hello-world","tag-hello-world-django","tag-python"],"_links":{"self":[{"href":"https:\/\/difusao.tech\/blog\/wp-json\/wp\/v2\/posts\/283","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/difusao.tech\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/difusao.tech\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/difusao.tech\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/difusao.tech\/blog\/wp-json\/wp\/v2\/comments?post=283"}],"version-history":[{"count":2,"href":"https:\/\/difusao.tech\/blog\/wp-json\/wp\/v2\/posts\/283\/revisions"}],"predecessor-version":[{"id":306,"href":"https:\/\/difusao.tech\/blog\/wp-json\/wp\/v2\/posts\/283\/revisions\/306"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/difusao.tech\/blog\/wp-json\/wp\/v2\/media\/292"}],"wp:attachment":[{"href":"https:\/\/difusao.tech\/blog\/wp-json\/wp\/v2\/media?parent=283"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/difusao.tech\/blog\/wp-json\/wp\/v2\/categories?post=283"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/difusao.tech\/blog\/wp-json\/wp\/v2\/tags?post=283"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}