django
서버실행
url 정규표현식
페이지 추가
community/models.py
from django.db import models
class Article(models.Model):
name = models.CharField(max_length=50)
title = models.CharField(max_length=50)
contents = models.TextField()
url = models.URLField()
email = models.EmailField()
cdate = models.DateTimeField(auto_now_add=True)
python manage.py makemigrations community
python manage.py migrate
urls.py
from community.views import *
urlpatterns = [
url(r'^write/', write, name='write'),
]
views.py
def write(request):
return render(request, 'write.html')
templates 폴더아래 write.html 생성
프로젝트 설치
mkdir myProj
cd myProj
python -m venv myvenv (리눅스 : source python -m venv myvenv)
myvenv\Scripts\activate
pip install django
django-admin startproject mysite . (프로젝트생성)
python manage.py startapp community (프로젝트 내부의 하위 카테고리)
python manage.py migrate (변경사항을 db 에 반영)
python manage.py createsuperuser
python manage.py runserver
=============================
manage.py
makemigrations app - app 의 모델변경사항 체크