Step#6. 장고 APP 생성하기

정은경·2019년 12월 23일
0

🎸 Play the Django 

목록 보기
11/57

1) 장고 APP 생성하기

python manage.py startpp 생성할앱이름

python manage.py startpp user
(test_project) marie@MarieJungui-MacBookPro:~/mynewdjango » pwd
/Users/marie/mynewdjango
(test_project) marie@MarieJungui-MacBookPro:~/mynewdjango »
(test_project) marie@MarieJungui-MacBookPro:~/mynewdjango » tree
.
├── manage.py
└── mynewjangodirec
    ├── __init__.py
    ├── asgi.py
    ├── settings.py
    ├── urls.py
    └── wsgi.py

1 directory, 6 files
(test_project) marie@MarieJungui-MacBookPro:~/mynewdjango »
(test_project) marie@MarieJungui-MacBookPro:~/mynewdjango » python manage.py startapp
usage: manage.py startapp [-h] [--template TEMPLATE] [--extension EXTENSIONS]
                          [--name FILES] [--version] [-v {0,1,2,3}]
                          [--settings SETTINGS] [--pythonpath PYTHONPATH]
                          [--traceback] [--no-color] [--force-color]
                          name [directory]
manage.py startapp: error: You must provide an application name.
(test_project) marie@MarieJungui-MacBookPro:~/mynewdjango »                                                                                                                                                                        2 ↵
(test_project) marie@MarieJungui-MacBookPro:~/mynewdjango » python manage.py startapp user                                                                                                                                         2 ↵
(test_project) marie@MarieJungui-MacBookPro:~/mynewdjango »
(test_project) marie@MarieJungui-MacBookPro:~/mynewdjango » pwd
/Users/marie/mynewdjango
(test_project) marie@MarieJungui-MacBookPro:~/mynewdjango » tree
.
├── manage.py
├── mynewjangodirec
│   ├── __init__.py
│   ├── __pycache__
│   │   ├── __init__.cpython-37.pyc
│   │   └── settings.cpython-37.pyc
│   ├── asgi.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
└── user
    ├── __init__.py
    ├── admin.py
    ├── apps.py
    ├── migrations
    │   └── __init__.py
    ├── models.py
    ├── tests.py
    └── views.py

4 directories, 15 files
(test_project) marie@MarieJungui-MacBookPro:~/mynewdjango »

2) 생성된 APP 파일 살펴보기

(test_project) marie@MarieJungui-MacBookPro:~/mynewdjango » pwd
/Users/marie/mynewdjango
(test_project) marie@MarieJungui-MacBookPro:~/mynewdjango » tree
.
├── manage.py
├── mynewjangodirec
│   ├── __init__.py
│   ├── __pycache__
│   │   ├── __init__.cpython-37.pyc
│   │   └── settings.cpython-37.pyc
│   ├── asgi.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
└── user
    ├── __init__.py
    ├── admin.py
    ├── apps.py
    ├── migrations
    │   └── __init__.py
    ├── models.py
    ├── tests.py
    └── views.py

4 directories, 15 files
(test_project) marie@MarieJungui-MacBookPro:~/mynewdjango »
(test_project) marie@MarieJungui-MacBookPro:~/mynewdjango »
(test_project) marie@MarieJungui-MacBookPro:~/mynewdjango » cat ./user/__init__.py
(test_project) marie@MarieJungui-MacBookPro:~/mynewdjango »
(test_project) marie@MarieJungui-MacBookPro:~/mynewdjango » cat ./user/admin.py                                                                                                                                                  127 ↵
from django.contrib import admin

# Register your models here.
(test_project) marie@MarieJungui-MacBookPro:~/mynewdjango »
(test_project) marie@MarieJungui-MacBookPro:~/mynewdjango » cat ./user/apps.py
from django.apps import AppConfig


class UserConfig(AppConfig):
    name = 'user'
(test_project) marie@MarieJungui-MacBookPro:~/mynewdjango »
(test_project) marie@MarieJungui-MacBookPro:~/mynewdjango » cat ./user/migrations
cat: ./user/migrations: Is a directory
(test_project) marie@MarieJungui-MacBookPro:~/mynewdjango » cat ./user/migrations/__init__.py                                                                                                                                      1 ↵
(test_project) marie@MarieJungui-MacBookPro:~/mynewdjango »
(test_project) marie@MarieJungui-MacBookPro:~/mynewdjango » cat ./user/models.py
from django.db import models

# Create your models here.
(test_project) marie@MarieJungui-MacBookPro:~/mynewdjango »
(test_project) marie@MarieJungui-MacBookPro:~/mynewdjango » cat ./user/tests.py
from django.test import TestCase

# Create your tests here.
(test_project) marie@MarieJungui-MacBookPro:~/mynewdjango »
(test_project) marie@MarieJungui-MacBookPro:~/mynewdjango » cat ./user/views.py
from django.shortcuts import render

# Create your views here.
(test_project) marie@MarieJungui-MacBookPro:~/mynewdjango »
profile
#의식의흐름 #순간순간 #생각의스냅샷

0개의 댓글