Programação Web - Como Fazer Um Projeto No Pycharm

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Como fazer um projeto no pycharm

pip install django

django-admin startproject mysite .

python manage.py makemigrations

python manage.py migrate

python manage.py createsuperuser

python manage.py startapp teste

mysite/urls.py mysite/settings

from django.contrib import admin INSTALLED_APPS = [

from django.urls import path, include 'django.contrib.admin',

'django.contrib.auth',

urlpatterns = [ 'django.contrib.contenttypes',

path('admin/', admin.site.urls), 'django.contrib.sessions',

path('', include('teste.urls')), 'django.contrib.messages',

] 'django.contrib.staticfiles',

'teste',

criar diretório “templates” dentro de “teste”

criar o file “index.html” dentro de templates e colocar as


coisas teste/models.py

from django.db import models

from django.utils import timezone

teste/urls.py teste/views.py
from django.urls import path class Post(models.Model):
from django.shortcuts
from teste import views import render titulo = models.CharField(max_length=120,
null=False, blank=False)

texto = models.TextField(null=False)
urlpatterns = [ def index(request):
data =
path("", views.index, return render(request,
models.DateTimeField(default=timezone.now)
name="index"), 'index.html',{})

You might also like