Python/Django

    [vscode django세팅] vscode에서 django 사용하기

    1. VSCode설치 뒤 열고자 하는 폴더 open 2. VSCode Extension 설치 3. venv 생성 python -m venv venv 4. Interpreter 설정 4-1. VSCode의 View > Command Pallette 실행 4-2. Python: Select Interpreter 실행 4-3. .\venv\Scripts\python.exe 선택 5. 기본 터미널 변경 5-1. VSCode의 View > Command Pallette 실행 5-2. Terminal: Select Default Shell 실행하여 Command Prompt 선택 (기본 터미널이 PowerShell이라 Error가 남) 5-3. Terminal: Create New Integrated Termina..

    django 와 mongodb연동

    1. MariaDB 원격 접속 1. 원격 접속이 가능한 사용자 계정을 root계정으로 접속해서 만든다. create user 'python'@'%' identified by 'python'; grant all on *.* to 'python'@'%'; flush privileges; #MySQL Database 생성 mysql -u root -p show databases; use mysql create user 'python'@'%' identified by 'python'; grant all on *.* to 'python'@'%'; flush privileges; exit; mysql -u python -p create database python_db; show databases; 2. DB서버 ..

    페이지네이션

    https://docs.djangoproject.com/en/3.0/topics/pagination/ Pagination | Django documentation | Django Django The web framework for perfectionists with deadlines. Overview Download Documentation News Community Code Issues About ♥ Donate docs.djangoproject.com 1. html파일 생성 [pagination.html] {% if page.has_previous %} Previous {% endif %} Page {{page.number}} of {{page.paginator.num_pages}} {% if pag..

    Django 댓글기능 추가

    - blog/urls.py from django.urls import path from . import views urlpatterns = [ # loacalhost:8080/ path('', views.post_list, name='post_list'), # localhost:8080/post/5 path('post//', views.post_detail, name='post_detail_test'), # localhost:8080/post/new path('post/new/', views.post_new, name='post_new'), # localhost:8080/post/5/edit path('post//edit', views.post_edit, name='post_edit'), # localh..

    Django 템플릿 상속 / 게시판 만들기

    1. 템플릿 상속 공통적으로 쓰는 코드를 하나 만들어 놓고 상속받아서 쓰는 것 바뀌는 부분만 block이라는 부분에 싸서 사용 - blog/templates/blog/base.html {% load static %} Django Blog {% block content %} {% endblock %} {% comment "Optional note" %} Server comment {% endcomment %} - blog/templates/blog/post_edit.html {% extends 'blog/base.html' %} {% block content%} {% for post in posts %} published : {{post.published_date}} {{post.title|title}} ..

    Django (Migrate / URLConf / View / Template / QuerySet / Bootstrap)

    1. admin.ModelAdmin -> list_display 사용하여 admin 게시판 리스트 양식 바꾸기 https://www.kite.com/python/docs/django.contrib.admin.ModelAdmin.list_display Kite - AI Coding Assistant for Python and JavaScript Code faster with Kite’s AI-powered autocomplete plugin for Python and JavaScript developers, featuring Multi-Line Completions. Works 100% locally. www.kite.com 1) 관리자 페이지에서 blog앱에 보이는 게시판 양식을 변경해보자 - 기존: t..

    Django설치 및 설정 & 간단한 게시판 만들기

    1. 세팅 - 파이썬 깔린 곳 위치 확인 - 파이썬 깔린 위치 확인 후, 다음과 같이 환경변수 추가 - PyCharm Terminal창에서 파이썬 version & Anaconda내장 파이썬 아닌 찐 파이썬 그 자체로 설정되있는지 확인 - PyCharm Terminal창에서 django 설치 - django 버전 확인 - django 설치 확인 2. Django 프로젝트 생성 - 자신이 원하는 폴더 아래 django_src라는 하위 폴더 생성 - Django 프로젝트 생성 명령어 - django_src폴더 안에 manage.py 파일과 자신이 지정한 이름의 폴더가 생성된 것을 볼 수 있다. - 폴더 안에는 다음과 같은 구성으로 돼있다. - manage.py : 웹사이트 관리를 도와주는 역할을 하는 파일 ..