learn_dj6

Run Settings
LanguagePython
Language Version
Run Command
uml(unified Modeling Language 統一塑模語言, 統一建模語言) u-->vmt django flowchart ================ browser--->request--->urls(project)--->urls(apps)--->views--->db+templates+static(render)--->html--->response --->templates+static(redirect) --->HttpResponse django messages control create django-python project editor-->IDE-->vscode, pycharm(python), IntelliJ IDEA(java), Eclipse, NetBeans -->GitHub Codespaces, AWS Cloud9 Integrated development environment 整合開發環境, 綜合開發環境 圖像用家介面(英文:graphical user interface,簡稱 GUI) Server Services =============== IAAS-infastructure PAAS-platform SAAS-software abc.com--->DNS(Domain Name System)--->IP--->server ubuntu-->nginx(firewall) request{header, status code, bear, json, params} ok return 200 subdomain (shop.abc.com, info.abc.com) abc.com/en/index (i18n) abc.com/tc/index or tc.abc.com en.abc.com urls-->routing-->app app-->urls-->endpoint view.f()-->sql template+data TMUX - remote terminal ====================== # - server $ - local 10.3.4、 tmux 多路終端機 ======================== https://linux.vbird.org/linux_server/rocky9/0230sshd.php#10.1 伺服器架設篇目錄 - RockyLinux 9 =============================== https://linux.vbird.org/linux_server/rocky9/ Command-line control login remotely from another computer ========================================================= https://www.redhat.com/en/blog/introduction-tmux-linux A beginner's guide to tmux ========================== https://www.redhat.com/en/blog/introduction-tmux-linux ===== canva ===== 1) ubuntu 2) sudo apt install zsh 3) sudo apt install git 4) Install oh-my-zsh 5) app center-->chromium, vscode 6) powerlevel9k, 10k 7) pyenv 8) virtualenvwrapper, mkvirtualenv, workon 9) SSH messages ======== messages.debug .info .success .warning .error MIDDLEWARE, TEMPLATES from django.contrib import messages messages.error(request, 'error!') {% if messages %} {% for message in messages %} <div class="alert alert-{{ message-tag }} alert-dismissible fade show" role="alert"> {{ message }} aws-->EC2 1) create new folder 2) open terminal 3) move folder to terminal 4) git init 5) create .gitignore file 6) workon virual env 7) pyenv local 3.12.8 (auto create .python-version) 8) django-admin startproject bre10 . 9) python manage.py runserver 10) python manage.py startapp newapps 11) in newprojet/settings INSTALLED_APPS = [ 'newapps.apps.newappsConfig', ] 12) in newapps/urls from django.urls import path from . import views urlpatterns = [ path = ('', views.index, name='index') ] 13) in newaproject/settings from django.urls import include urlpathers = [ path('', include(newapps.urls)) ] 14) in newapps/views from django.shortcut import render from django.http import HttpResponse def index(request): return(HttpResponse('<h2>Hello, World!</h2>') 15) in bre10/settings import os TEMPLATES = [ 'DIRS': [os.path.join(BASE_DIR, 'templates')], ] create templates/newapps/index.html in index.html <h1>index</h1> 16) in bre10/settings STATIC_ROOT = os.path.join(BASE_DIR, 'static') STATIC_URL = 'static/' STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'bcr10/static'), ] python manage.py collectstatic 17) python manage.py migrate 18) python manage.py createsuperuser 19) modify models.py from django.db import models # Create your models here. class Test(models.Model): name = models.CharField(max_length=100) def __str__(self): return self.name python manage.py makemigrations python manage.py migrate 20) from django.contrib import admin from .models import Test # Register your models here. class TestAdmin(admin.ModelAdmin): list_display = ('id', 'name', ) list_display_links = ('id', 'name',) list_filter = 'name', search_fields = 'name', list_per_page = 12 admin.site.register(Test, TestAdmin) ======================================================== git === What's the difference between 'git switch' and 'git checkout' <branch>? ======================================================================= https://stackoverflow.com/questions/57265785/whats-the-difference-between-git-switch-and-git-checkout-branch 1) sudo apt-get update sudo apt-get install git git --version 2) git config --global user.name "Your name" git config --global user.email "123@abc.com" git config --global core.editor "code" .gitconfig 3) mkdir myproject cd myproject git init 4) git clone https://github/username/repository.git 5) git add. git commit -m "message" git push -u origin main git pull git fetch 6) git checkout -b newbranch or git branch newbranch git checkout newbranch ----------------------- git checkout branchname git merge branchname git branch -d branchname 7) git remote add origin https://github.com/username/repository.git git remote add origin git@github.com:ykgoal/erb4.git 8) git remote add origin .git git push origin main git pull origin main 9) merge a) Fast-Forward Merge git merge --ff-only branchname b) Three-Way Forward Merge git merge branchname a) No Fast-Forward Merge git merge --no-ff branchname 10) .gitignore git === pwd ls, ls -l, ll lsb_release -a git status git status -s git ls-files --stage git log --oneline --all --graph git add . git commit -m "step 1" undo commit =========== revert (extra commit) git reset hard git reset mixed git reset soft
Editor Settings
Theme
Key bindings
Full width
Lines