본문 바로가기

분류 전체보기402

sequence자료형 1. 문자열'(작은따옴표), "(큰따옴표)를 사용하여 만든다.여러줄 문자열 생성  -   """여러줄 문자열"""                                            '''여러줄 문자열'''문자열내 작은따옴표,큰따옴표가 있으면 그외 기호로 문자열을 묶어주거나 \'  나 \" 처럼 escape문자 사용하라!!!>>> s = "Python isn't difficult">>> s"Python isn't difficult">>> 'Python isn\'t difficult'"Python isn't difficult" 2. 리스트빈 리스트리스트 = []리스트 = list()>>> a = []>>> a[]>>> b = list()>>> b[] range를 이용한 리스트 만들기range(횟수.. 2023. 9. 29.
bool / 비교연산자 / 논리연산자 boolTrue, False 비교연산자 ( 값 비교 )==    !=    >    =      하나의 변수에 비교연산자 2개 연결 사용 가능!!!if 11   ※ 객체 비교에는 is, is not 이용※ 객체의 메모리 주소 확인 : id(객체) 논리연산자and, or, not 단락 평가논리 연산에서 중요한 부분이 단락 평가(short-circuit evalution)입니다. 단락 평가는 첫 번째 값만으로 결과가 확실할 때 두 번째 값은 확인(평가)하지 않는 방법을 말합니다. 즉, and 연산자는 두 값이 모두 참이라야 참이므로 첫 번째 값이 거짓이면 두 번째 값은 확인하지 않고 바로 거짓으로 결정합니다.특히 파이썬에서 논리 연산자는 이 단락 평가에 따라 반환하는 값이 결정됩니다. 파이썬에서 논리 연산자.. 2023. 9. 29.
연산자 / 변수 숫자 체계- 자료형 확인 : type함수 이용- 자료형 변환 : int, float, complex함수 이용 연산자x + y덧셈x 왼쪽으로 비트 시프트(shift)x - y뺄셈x >> n오른쪽으로 비트 시프트x * y곱셈x & yAND 비트 연산x / y나눗셈(부동소수점수를 생성)x | yOR 비트 연산x // yFloor 나눗셈(몫을 생성:정수)x ^ yXOR 비트 연산x % y모듈로 연산자(나머지)~xNOT 비트 연산x ** y제곱  abs(x)절댓값  divmod(a,b)결과: (몫,나머지)   >>> quotient, mod = divmod(5, 2)>>> print(quotient, mod)2 1 진수표현 2진수    : 0b110    -> 68진수    : 0o110    -> 7216진수 .. 2023. 9. 28.
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.