티스토리 뷰
(macOS)[python][django][RaspberryPi] ERP platform - 1
jinozpersona 2021. 4. 15. 14:21Local / Server 구동 비교
ERP Menu hyperlink Test : urls - views - templates 관계 이해
Server Test : git transmission
INTRO
* local / server terminal 구분 : [macOS] / [Raspi]
** venv 표기 : (pyERP)
Raspi : server
- Python : 3.7.3
- django : 3.2
macOS : local-dev
- Python : 3.9.4
- django : 3.2
1. superuser
Django Admin 상태
macOS : local-dev
http://localhost:8000/admin
Raspi : server
http://[RaspiIP]:xxxx/admin
SuperUser 생성
[macOS](pyERP)$ ./manage.py createsuperuser
사용자 이름 (leave blank to use 'UserID'):
이메일 주소:
Password:
Password (again):
Superuser created successfully.
login 화면
[Raspi](pyERP)$ ./manage.py createsuperuser
login 화면
2. app test : url / view / template 관계 이해하기
# config/urls.py, app/urls.py <-> app/views <-> app/templates
django project 전체 home에 index_welcome.html에서 index_app.html로 이동하는 예제
[macOS](pyERP)$ ./manage.py startapp tapp
{SublimeText} config/settings.py
INSTALLED_APPS = [
'tapp',
'django.contrib.admin',
...
]
2.1. urls
[macOS](pyERP)$ touch tapp/urls.py
{SublimeText} tapp/urls.py
from django.contrib import admin
from django.urls import path
from tapp import views
urlpatterns = [
path('', views.index_app, name='index_app'),
]
{SublimeText} config/urls.py
from django.contrib import admin
from django.urls import path, include
from tapp import views
urlpatterns = [
path('admin/', admin.site.urls),
path('', views.index, name='index'),
path('tapp/', include("tapp.urls")),
]
2.2. views
{SublimeText} tapp/views.py
# -*- coding: utf-8 -*-
from django.shortcuts import render
def index(request):
return render(request, 'index.html')
def index_app(request):
return render(request, 'index_app.html')
2.3. templates
[macOS](pyERP)$ mkdir tapp/templates
[macOS](pyERP)$ touch tapp/templates/index.html
[macOS](pyERP)$ touch tapp/templates/index_app.html
{SublimeText} tapp/templates/index.html
<!DOCTYPE html>
<head>
<title>index</title>
<meta charset="utf-8">
<td><a href="{% url 'index' %}"><B>Home</B></a></td>
<td><a href="{% url 'index_app' %}"><B>tapp</B></a></td>
</head>
<body>
<br><br>
"This is hyper-link Test page"
<br><br>
url : /
<br>
index page
<br>
"Here is body of index.html"
</body>
{SublimeText} tapp/templates/index_app.html
<!DOCTYPE html>
<head>
<title>index_app</title>
<meta charset="utf-8">
<td><a href="{% url 'index' %}"><B>Home</B></a></td>
<td>tapp</td>
</head>
<body>
<br><br>
url : /tapp/
<br>
index_app page
<br>
"Here is body of index_app.html"
</body>
[macOS](pyERP)testerp$ tree
.
├── config
│ ├── __init__.py
│ ├── asgi.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
├── db.sqlite3
├── manage.py
├── secret.json
└── tapp
├── __init__.py
├── admin.py
├── apps.py
├── migrations
│ └── __init__.py
├── models.py
├── templates
│ ├── index.html
│ └── index_app.html
├── tests.py
├── urls.py
└── views.py
macOS : local-dev
[macOS](pyERP)$ ./manage.py runserver
http://localhost:8000/
tapp hyperlink click
3. Server Test : git transmission
git push : local
[macOS]testerp$ git init
[macOS] git:(master)$ git add .
[macOS] git:(master)$ git commit -m "3rd : tapp test"
[macOS] git:(master)$ git remote add origin https://github.com/YourRepoName.git
[macOS] git:(master)$ git push -f origin master
git pull/fetch : server
[Raspi]testerp$ git init
Initialized empty Git repository in ~/.virtualenvs/pyERP/testerp/.git/
[Raspi]testerp$ git remote add origin https://github.com/YourRepoName.git
[Raspi]testerp$ git pull
[Raspi]testerp$ git fetch --all
Fetching origin
Username for 'https://github.com': [YourGitHubID]
Password for 'https://[YourID]@github.com': [YourGitHubPass]
[Raspi](pyERP)testerp$ git reset --hard origin/master
#참고 git 종료 : local / server
$ rm -r .git
Server Test
[Raspi]pyERP$ source bin/activate
[Raspi](pyERP)$ cd testerp
[Raspi](pyERP)testerp$ nano config/settings.py
#ALLOWED_HOSTS = ['localhost']
ALLOWED_HOSTS = ['[RaspiIP]']
[Raspi](pyERP)testerp$ uwsgi --ini testerp.ini
server 구동 확인 : local과 동일
http://[RaspiIP]:xxxx/
'python > django_ERP1' 카테고리의 다른 글
(macOS)[python][django][RaspberryPi] ERP platform - 3 (0) | 2021.04.23 |
---|---|
(macOS)[python][django][RaspberryPi] ERP platform - 2 (0) | 2021.04.19 |
(macOS)[python][django][RaspberryPi] ERP platform - SECRET_KEY 보안설정 (0) | 2021.04.14 |
(macOS)[python][django][RaspberryPi] ERP platform - local/server Test (0) | 2021.04.14 |
(macOS)[python][django][RaspberryPi] ERP platform - git (0) | 2021.04.07 |
- Total
- Today
- Yesterday
- Pandas
- 코로나
- server
- github
- Django
- MacOS
- analysis
- SSH
- DS18B20
- COVID-19
- 자가격리
- Raspberry Pi
- arduino
- Templates
- raspberrypi
- template
- git
- r
- ERP
- Model
- CSV
- 확진
- sublime text
- Regression
- pyserial
- DAQ
- Python
- vscode
- 코로나19
- 라즈베리파이
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |