티스토리 뷰

Templates Structure

root template : base.html

static : css 적용

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

 

 

macOS : local-dev

1. Templates Structure

[macOS](pyERP)testerp$ ./manage.py startapp home

 

settings : Add app.

{SublimeText} config/settings.py

# Application definition

INSTALLED_APPS = [
    'home',
    'tapp',
    ....
]

....

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
                os.path.join(BASE_DIR, 'templates'),
                ],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

....

STATIC_URL = '/static/'
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static'),
]
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

 

urls : config/urls

{SublimeText} config/urls.py

from django.contrib import admin
from django.urls import path, include
from tapp import urls
from home import views


urlpatterns = [
    path('admin/', admin.site.urls),
    path('', views.index_home, name='index_home'),
    path('tapp/', include("tapp.urls")),
]

 

views : index_home

{SublimeText} home/views.py

# -*- coding: utf-8 -*-

from django.shortcuts import render
from tapp.models import SalesData


def index_home(request):
	SalesDatas = SalesData.objects.all()
	context = {'SalesDatas':SalesDatas}
	return render(request, 'index_home.html', context)

 

2. base.html

templates : base.html

[macOS](pyERP)testerp$ mkdir templates

[macOS](pyERP)testerp$ touch templates/base.html

{SublimeText} erptest/templates/base.html

{% load static %}
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>index_base_root</title>
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <link rel="stylesheet" href="{% static 'css/style_home.css' %}">
  </head>

  <body>
    <div id="container">
      <div id="header">
        <!-- <h1>Responsive Layout</h1> -->
        <div class="logo">
          <a href="#"><img src="{% static 'img/logo_w_persona.png' %}" width="140" height="38"></a>
        </div>
          
        <div class="search-item">
          <input type="search" name="q" placeholder="Search query">
          <input type="submit" value="Go!">
        </div>
        <div class="h-item">Login Form</div>
      </div>

      <nav class="nav_main">
        <ul>
          <li><a href="#">Management</a></li>
          <li><a href="#">Sales</a></li>
          <li><a href="#">Production</a></li>
          <li><a href="#">Quality</a></li>
          <li><a href="#">Anlysis</a></li>
        </ul>
      </nav>

      <div id="m-content">
      <!-- <h2>Main-Content</h2> -->
      {% block content1 %}
      {% endblock %}
      </div>

      <nav class="nav_sub">
        <ul>
          <li><a href="#">Sub1</a></li>
          <li><a href="#">Sub2</a></li>
          <li><a href="#">Sub3</a></li>
        </ul>
      </nav>

      <div id="s-content">
      {% block content2 %}
      {% endblock %}
      </div>

    <div id="footer">
      <p>Copyright © PERSONA All rights reversed.</p>
    </div>
    </div>
  </body>
</html>

 

templates : home/templates/index_home.html

      {% extends 'base.html' %}
      {% block content1 %}
      <!-- Main content -->
        <!-- List_head -->
        <h2>Main-Content</h2>
        <table>
          <thead>
            <tr>
              <td><B>No.</B></td>
              <td><B>Company</B></td>
              <td><B>Site</B></td>
              <td><B>Customer</B></td>
              <td><B>제품구분</B></td>
              <td><B>품명</B></td>
              <td><B>수량</B></td>
              <td><B>납품일</B></td>
              <td><B>DrawingID</B></td>
              <td><B>FrameID</B></td>
              <td><B>비고</B></td>
            </tr>
          </thead>

          <!-- List_script -->
          <tbody>
            {% for SalesData in SalesDatas %}
            <tr>
              <td><a href="#">{{SalesData.num_cnt}}</a></td>
              <td>{{SalesData.company}}</td>
              <td>{{SalesData.site}}</td>
              <td>{{SalesData.customer}}</td>
              <td>{{SalesData.category}}</td>
              <td>{{SalesData.item}}</td>
              <td>{{SalesData.quantity}}</td>
              <td>{{SalesData.dateShip}}</td>
              <td>{{SalesData.drawID}}</td>
              <td>{{SalesData.frameID}}</td>
              <td>{{SalesData.note}}</td>
            </tr>
            {% endfor %}
          </tbody>
        </table>
      <!-- End Main content -->
      {% endblock %}
      

      {% block content2 %}
      <h2>Sub-Content</h2>
      <table class="tg" style="undefined;table-layout: fixed; width: 800px">
          <colgroup>
          <col style="width: 50px">
          <col style="width: 240px">
          <col style="width: 70px">
          <col style="width: 70px">
          <col style="width: 70px">
          <col style="width: 70px">
          <col style="width: 70px">
          <col style="width: 70px">
          <col style="width: 70px">
          <col style="width: 70px">
          </colgroup>

        <thead>
          <tr>
            <th class="tg-jbyd" colspan="2" rowspan="2">Logo position</th>
            <th class="tg-ymap" colspan="8" rowspan="2">견&nbsp;&nbsp;적&nbsp;&nbsp;서</th>
          </tr>
          <tr></tr>
        </thead>

        <tbody>
          <tr>
            <td class="tg-wp8o" colspan="3">{{Quotation.company}}</td>
            <td class="tg-wp8o" colspan="2"></td>
            <td class="tg-j4pq">상호</td>
            <td class="tg-j4pq" colspan="4">PERSONA</td>
          </tr>
          <tr>
            <td class="tg-wp8o" colspan="3">{{Quotation.customer}}</td>
            <td class="tg-wp8o" colspan="2">귀중</td>
            <td class="tg-j4pq">주소</td>
            <td class="tg-j4pq" colspan="4">https://jinozblog.tistory.com/</td>
          </tr>
          <tr>
            <td class="tg-73oq" colspan="5" rowspan="2">아래와 같이 견적합니다.</td>
            <td class="tg-j4pq">업태</td>
            <td class="tg-j4pq">제조</td>
            <td class="tg-j4pq">종목</td>
            <td class="tg-j4pq" colspan="2">Machine Parts</td>
          </tr>
          <tr>
            <td class="tg-fm1z">연락처</td>
            <td class="tg-fm1z" colspan="4">+82-10-0000-0000</td>
          </tr>
          <tr>
            <td class="tg-73oq" colspan="10"></td>
          </tr>
          <tr>
            <td class="tg-wp8o">No.</td>
            <td class="tg-wp8o" colspan="2">Product</td>
            <td class="tg-wp8o">Material</td>
            <td class="tg-wp8o">Size</td>
            <td class="tg-wp8o">Quantity</td>
            <td class="tg-wp8o">Cost</td>
            <td class="tg-wp8o">Sum</td>
            <td class="tg-wp8o" colspan="2">Note</td>
          </tr>
          <tr>
            <td class="tg-wp8o">1</td>
            <td class="tg-wp8o" colspan="2">{{Quotation.item}}</td>
            <td class="tg-wp8o">{{Quotation.category}}</td>
            <td class="tg-wp8o">{{Quotation.layer}}</td>
            <td class="tg-wp8o">{{Quotation.quantity}}</td>
            <td class="tg-wp8o"></td>
            <td class="tg-wp8o"></td>
            <td class="tg-wp8o" colspan="2"></td>
          </tr>
          <tr>
            <td class="tg-wp8o">2</td>
            <td class="tg-wp8o" colspan="2"></td>
            <td class="tg-wp8o"></td>
            <td class="tg-wp8o"></td>
            <td class="tg-wp8o"></td>
            <td class="tg-wp8o"></td>
            <td class="tg-wp8o"></td>
            <td class="tg-wp8o" colspan="2"></td>
          </tr>
          <tr>
            <td class="tg-wp8o">3</td>
            <td class="tg-wp8o" colspan="2"></td>
            <td class="tg-wp8o"></td>
            <td class="tg-wp8o"></td>
            <td class="tg-wp8o"></td>
            <td class="tg-wp8o"></td>
            <td class="tg-wp8o"></td>
            <td class="tg-wp8o" colspan="2"></td>
          </tr>
          <tr>
            <td class="tg-wp8o">4</td>
            <td class="tg-wp8o" colspan="2"></td>
            <td class="tg-wp8o"></td>
            <td class="tg-wp8o"></td>
            <td class="tg-wp8o"></td>
            <td class="tg-wp8o"></td>
            <td class="tg-wp8o"></td>
            <td class="tg-wp8o" colspan="2"></td>
          </tr>
          <tr>
            <td class="tg-wp8o">5</td>
            <td class="tg-wp8o" colspan="2"></td>
            <td class="tg-wp8o"></td>
            <td class="tg-wp8o"></td>
            <td class="tg-wp8o"></td>
            <td class="tg-wp8o"></td>
            <td class="tg-wp8o"></td>
            <td class="tg-wp8o" colspan="2"></td>
          </tr>
          <tr>
            <td class="tg-wp8o" colspan="5">합계</td>
            <td class="tg-73oq" colspan="5"></td>
          </tr>
          <tr>
            <td class="tg-xwyw" rowspan="2" colspan="1">특이사항</td>
            <td class="tg-73oq" colspan="9">VAT별도</td>
          </tr>
          <tr>
            <td class="tg-73oq" colspan="9">대금지급 / 납기 별도 협의</td>
          </tr>
        </tbody>
      </table>
      {% endblock %}

 

3. css

css : static/style_home.css

/* # : id, . : class */
#container {
  width: auto;
  padding: 5px;
  border: 1px solid #bcbcbc;
}

#header {
  height: 45px;
  padding: 1px;
  margin-bottom: 5px;
  border: 1px solid #bcbcbc;
  display: flex;
  align-items: center;
}

.logo {
  margin: 5px;
  padding: 5px;
}

.h-item {
  margin: 5px;
  padding: 10px;
}

.search-item {
  padding: 5px;
}

.nav_main {
  height:24px;
  background-color: #000000;
  display: flex;
  align-items: center;
}

.nav_sub {
  height:18px;
  background-color: #808080;
  display: flex;
  align-items: center;
}

nav ul {
  padding: 5px;
  display: flex;
}

nav li {
  display: inline;
  padding-left: 20px;
}

nav a {
  display: inline-block;
  font-size: 18px;
  text-transform: uppercase;
  text-decoration: none;
  color: white;
}

#m-content {
  width: auto;
  padding: 10px;
  margin-top: 5px;
  margin-bottom: 5px;
  border: 2px solid #000080;
}

#s-content {
  width: auto;
  padding: 10px;
  margin-top: 5px;
  margin-bottom: 5px;
  border: 2px solid #008080;
}

#footer {
  clear: both;
  padding-left: 10px;
  border: 1px solid #bcbcbc;
}


/*sub-content : table style*/
.tg  {border-collapse:collapse;border-spacing:0;}
.tg td{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;
  overflow:hidden;padding:8px 10px;word-break:normal;}
.tg th{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;
  font-weight:normal;overflow:hidden;padding:8px 10px;word-break:normal;}
.tg .tg-j4pq{background-color:#efefef;border-color:#000000;text-align:center;vertical-align:top}
.tg .tg-wp8o{border-color:#000000;text-align:center;vertical-align:top}
.tg .tg-jbyd{background-color:#ffffff;border-color:#000000;text-align:center;vertical-align:top}
.tg .tg-ymap{background-color:#ffffff;border-color:#000000;font-family:Arial, Helvetica, sans-serif !important;;font-size:28px;
  text-align:center;vertical-align:middle}
.tg .tg-73oq{border-color:#000000;text-align:left;vertical-align:top}
.tg .tg-fm1z{background-color:#f0f0f0;border-color:#000000;text-align:center;vertical-align:top}
.tg .tg-xwyw{border-color:#000000;text-align:center;vertical-align:middle}

 

[macOS](pyERP)testerp$ ./manage.py collectstatic

[macOS](pyERP)testerp$ tree

.

├── config

│   ├── __init__.py

│   ├── __pycache__

│   ├── asgi.py

│   ├── settings.py

│   ├── urls.py

│   └── wsgi.py

├── db.sqlite3

├── home

│   ├── __init__.py

│   ├── __pycache__

│   ├── admin.py

│   ├── apps.py

│   ├── migrations

│   ├── models.py

│   ├── templates

│   │   ├── index_home.html

│   │   └── index_home_detail.html

│   ├── tests.py

│   ├── urls.py

│   └── views.py

├── manage.py

├── secret.json

├── static

│   ├── admin

│   ├── css

│   │   └── style_home.css

│   ├── img

│   │   └── logo_w_persona.png

│   └── js

├── staticfiles

│   ├── admin

│   ├── css

│   │   └── style_home.css

│   ├── img

│   │   └── logo_w_persona.png

│   └── js

├── tapp

│   ├── __init__.py

│   ├── __pycache__

│   ├── admin.py

│   ├── apps.py

│   ├── migrations

│   ├── models.py

│   ├── templates

│   │   ├── index.html

│   │   ├── index_app.html

│   │   ├── quotation.html

│   │   └── tapp_list.html

│   ├── tests.py

│   ├── urls.py

│   └── views.py

└── templates

    └── base.html

 

browser : localhost:8000 

 

--> No.의 번호 클릭 시 견적서에 해당 내용 불러오기

4. Server Test : git transmission

git push macOS : local-dev

[macOS]testerp$ git init

[macOS] git:(master)$ git add .

[macOS] git:(master)$ git commit -m "4th : 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 @ Raspi : server

[Raspi]testerp$ git init

[Raspi]testerp$ git remote add origin https://github.com/YourRepoName.git

[Raspi]testerp$ git pull

[Raspi]testerp$ git fetch --all

[Raspi](pyERP)testerp$ git reset --hard origin/master

 

 

Server Test @ Raspi : server

[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 Test 결과와 동일, 내용 생략

 

반응형
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/07   »
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
글 보관함