전체 글408 조건문 if 조건문에서 코드를 생략하기>>> x = 10>>> if x == 10:... pass...>>> if 다음 줄에 pass라는 특별한 키워드를 넣었습니다. 여기서 pass는 아무 일도 하지 않고 그냥 넘어간다는 뜻입니다. 파이썬에서는 if 다음 줄에 아무 코드도 넣지 않으면 에러가 발생하므로 if 조건문의 형태를 유지하기 위해 pass를 사용합니다.if x == 10: pass # TODO: x가 10일 때 처리가 필요함 True, False로 취급하는 것들 다음은 파이썬 문법 중에서 False로 취급하는 것들입니다.클래스 인스턴스의 __bool__(), __len__() 메서드가 0 또는 False를 반환 NoneFalse0인 숫자들: 0, 0.0, 0j비어 있는 문자열, 리.. 2023. 10. 2. generic views 2023. 5. 6. 함수 views C:\projects\noori\polls\admin.py from django.contrib import admin from .models import Question admin.site.register(Question) C:\projects\noori\polls\models.py from django.db import models from django.utils import timezone from datetime import datetime # Create your models here. class Question(models.Model): question_text = models.CharField(max_length=200) pub_date = models.DateTimeField('date pu.. 2023. 5. 6. style 적용 1. 3rd party 사용 1) package install ex) crispy (noori) c:\projects\noori>pip install crispy-bootstrap5 2) 설정 C:\projects\noori\config\settings.py INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', # 3rd Party 'crispy_forms', 'crispy_bootstrap5', # pip install crispy-bo.. 2023. 5. 4. Custom User Model(사용자 지정 User Model) 0. 준비 작업 1) common app 생성 - 사용자 관리 / 공통요소 작업 위해 (noori) c:\projects\noori $ python manage.py startapp common common 폴더 생성됨 : C:\projects\noori\common 2) works app 생성 C:\projects\noori\works 3) templates 폴더 생성 C:\projects\noori\templates C:\projects\noori\templates\common 4) createsuperuser 생성 (noori) c:\projects\noori>python manage.py createsuperuser 1. settings.py 설정 대상 파일 : config / settings.p.. 2023. 5. 3. [ Django ] 기타 설정 Then we need to update our static settings so it will be used in production. In your text editor open settings.py. Add whitenoise to the INSTALLED_APPS above the builtin staticfiles app and also to MIDDLEWARE on the third line. Order matters for both INSTALLED_APPS and MIDDLEWARE. At the bottom of the file add new lines for both STATIC_ROOT and STATICFILES_STORAGE. It should look like the follow.. 2023. 5. 3. [ Django ] 내장 인증 새 프로젝트를 만들 때마다 기본적으로 Django는 다음을 포함하는 User 객체를 제공하는 auth 앱을 설치합니다 . username password email first_name last_name 이 User 개체를 사용하여 블로그 애플리케이션에서 log in, log out, sign up 을 구현합니다. 준비 작업 1. (default)저장 폴더 생성 - 반드시 이 위치에 생성 templates/registration 2. config/settings.py 에 Login, Logout redirect url 지정 LOGIN_REDIRECT_URL = 'home' LOGOUT_REDIRECT_URL = 'home' 3. 사용 base.html - 로그인 상태에 따른 상태 표시 project / t.. 2023. 5. 3. [ Django ] django Views 1. Django 준비 작업 - app등록 대상파일 : projects /mysite / config / setting.py INSTALLED_APPS = [ "django.contrib.admin", "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", # Local App "pybo.apps.PyboConfig", ] - 관리자 모드에 Article 모듈 등록 대상파일 : projects /mysite / config / apps.py from django.contrib import admin from .mod.. 2023. 5. 2. [ Django ] Index 1. Django 설치 2. app 설치 3. views 2023. 5. 2. 이전 1 ··· 10 11 12 13 14 15 16 ··· 46 다음