Backend/Django

    django 08. POST 통신을 이용한 DB 데이터 저장 실습

    hello_world.html {% extends 'base.html' %} {% block content %} Hello world List! {% csrf_token %} {% if hello_world_list %} {% for hello_world in hello_world_list %} {{ hello_world.text }} {% endfor %} {% endif %} {% endblock %} input태그에 입력한 값 post버튼 누룰시 post방식으로 request 서버 request받아 html로 다시 response 저장한 데이터 불러와서 for구문으로 출력 views.py def hello_world(request): if request.method == "POST": # hello..

    django 07. model, DB 연동하기

    models.py 작성 from django.db import models # Create your models here. class HelloWorld(models.Model): text = models.CharField(max_length=255, null=False) HelloWorld라는 테이블의 text 필드값 생성 데이터베이스 반영 python manage.py makemigrations python manage.py migration sqlite db 반영 완료

    django 06. static 설정 및 css 파일 분리

    static 파일 정적 파일로 css, html 등 자주 변경하지 않는 파일 지칭 static 폴더 만들어 따로 관리함 settings.py STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') STATICFILES_DIRS = [ BASE_DIR / "static", ] static 파일 정의 추가(STATIC_ROOT) css 파일 header, footer 만들어 정의 및 설정 추가 {% load static %} static/base.css CSS파일 따로 만들어 관리 static 관련 파일 링크 추가

    django 05. style, 구글 폰트, 네이버 글꼴을 통해 Header, Footer 꾸미기

    부트스트랩 설치 pip install django-bootstrap4 https://django-bootstrap4.readthedocs.io/en/latest/installation.html Installation — django-bootstrap4 3.0.1 documentation © Copyright 2020, Dylan Verheul. Revision f63fec08. django-bootstrap4.readthedocs.io Settings.py 등록 INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contr..

    django 04. include/ extends / block 구문을 이용한 뼈대 html 만들기

    - template 및 extends 할 수 있는 뼈대html 만들기 Pragmatic span1 span2 span3 메인 App >templates > header.html 생성 공지사항 | 제휴문의 | 소개 Pragmatic 메인 App >templates > footer.html 생성 - accountapp 의 templates(.html) 폴더 생성 후 탬플릿 사용하기 accountapp 밑에 templates 밑에 app이름과 동일한 accountapp이름의 폴더를 또 생성해주는 이유는 url설정 시 구분하기 쉽도록 하기 위함

    django 03. 장고 template의 extends, include 구문과 render 함수

    1. 장고에서 extends와 include 차이 - extends : 미리 만들어 놓은 html파일을 가져와서 이것을 바탕으로 template 채워나는 구조 - include : 조그만 조각같은 것을 가져와 붙이는 개념 2. templates 폴더 만들고 html 파일 안에 생성 {% extends 'base.html' %} {% block content %} {% csrf_token %} {% endblock %} hello_world.html 파일 생성 main App에서 작성한 base.html 로 뼈대 구성 후 extends로 안에 내용만 수정 account > views.py 에 html 등록 3. settings.py 에 TEMPLATES안에 생성한 template 등록 TEMPLATES =..

    django 02. Git 활성화, 환경변수 분리, commit

    .gitignore 파일 생성 https://github.com/github/gitignore/blob/master/Global/JetBrains.gitignore GitHub - github/gitignore: A collection of useful .gitignore templates A collection of useful .gitignore templates. Contribute to github/gitignore development by creating an account on GitHub. github.com # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebSto..

    django 01. 첫 앱 시작, 그리고 기본적인 view 만들기

    장고 앱 생성 터미널 창에 accountapp 이라는 App 생성 python manage.py startapp accountapp 1. account App > view.py > hello world 이름의 변수 생성 Hello world!!! 문자 return 2. main App > urls.py 주소 등록 from django.contrib import admin from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), path('account/', include('accountapp.urls')), ] path 경로에서 accountapp 하위에 있는 url들 참조 기본적으로 localhost:80..