F:\github\django_blog(main -> origin)
(venv) λ python manage.py startapp blog
F:\github\django_blog(main -> origin)
(venv) λ ls
blog/ db.sqlite3 do_it_django_prj/ manage.py* README.md venv/
F:\github\django_blog(main -> origin)
(venv) λ python manage.py startapp single_pages
F:\github\django_blog(main -> origin)
(venv) λ git add .
F:\github\django_blog(main -> origin)
(venv) λ git commit -m "blog 앱과 single_pages 앱 생성"
[main f67e2bb] blog 앱과 single_pages 앱 생성
14 files changed, 36 insertions(+)
create mode 100644 blog/__init__.py
create mode 100644 blog/admin.py
create mode 100644 blog/apps.py
create mode 100644 blog/migrations/__init__.py
create mode 100644 blog/models.py
create mode 100644 blog/tests.py
create mode 100644 blog/views.py
create mode 100644 single_pages/__init__.py
create mode 100644 single_pages/admin.py
create mode 100644 single_pages/apps.py
create mode 100644 single_pages/migrations/__init__.py
create mode 100644 single_pages/models.py
create mode 100644 single_pages/tests.py
create mode 100644 single_pages/views.py
F:\github\django_blog(main -> origin)
(venv) λ git push
Enumerating objects: 13, done.
Counting objects: 100% (13/13), done.
Delta compression using up to 16 threads
Compressing objects: 100% (10/10), done.
Writing objects: 100% (12/12), 1.05 KiB | 535.00 KiB/s, done.
Total 12 (delta 3), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (3/3), completed with 1 local object.
To https://github.com/a/django_blog.git
f8533b2..f67e2bb main -> main
F:\github\django_blog(main -> origin)
(venv) λ python manage.py makemigrations
No changes detected
F:\github\django_blog(main -> origin)
(venv) λ python manage.py makemigrations
Migrations for 'blog':
blog\migrations\0001_initial.py
- Create model Post
F:\github\django_blog(main -> origin)
(venv) λ python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, blog, contenttypes, sessions
Running migrations:
Applying blog.0001_initial... OK
setting.py
TIME_ZONE = 'Asia/Seoul'
USE_I18N = True
USE_TZ = False
model.py
class Post(models.Model):
title = models.CharField(max_length=30)
content = models.TextField()
#auther : 추후 작성 예정정
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
def __str__(self):
return f'[{self.pk}] {self.title}'
F:\github\django_blog(main -> origin)
(venv) λ python manage.py makemigrations
Migrations for 'blog':
blog\migrations\0002_post_updated_at_alter_post_created_at.py
- Add field updated_at to post
- Alter field created_at on post
F:\github\django_blog(main -> origin)
(venv) λ python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, blog, contenttypes, sessions
Running migrations:
Applying blog.0002_post_updated_at_alter_post_created_at... OK
장고 셸 사용하기
F:\github\django_blog(main -> origin)
(venv) λ python manage.py shell
Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from blog.models import Post
>>> p = Post.objects.last()
>>> p.title
'시간 자동으로 저장하기'
>>> p.created_at
datetime.datetime(2022, 5, 25, 17, 14, 33, 67)
>>> p.updated_at
datetime.datetime(2022, 5, 25, 17, 15, 37, 805592)
>>> exit()
'PYTHON' 카테고리의 다른 글
[Django] InconsistentMigrationHistory 오류 (0) | 2023.10.24 |
---|---|
[Django] LoginRequiredMixin, UserPassesTestMixin (0) | 2023.10.24 |
[파이썬] Fillow 라이브러리 설치 (1) | 2023.10.24 |
[파이썬] 장고 설치 / 프로젝트 생성 (0) | 2023.10.24 |
[파이썬] 가상환경 만들기 (0) | 2023.10.24 |