본문 바로가기

BackEnd/PYTHON, Django

CREATE SU > python manage.py createsuperuser >> username >> email address >> password
Models & Migration :: Models - Django create table per model - Django model looks like from django.db import models class Model_name(inheritance) : variable1 = models.CharfField(constraints) variable2 = models.URLField(constraints) variable3 = models.DateTimeField(constraints) :: Migration - update database schema > python manage.py makemigrations > python manage.py migrate
Django ORM - database agnostic - only need driver(Adapter) - ORM -> Object-relational mappers - SQL vs Django ORM SQL> SELECT * FROM users WHERE country = "korea" ORDER BY signup_date Django> User.objs.filter(country ="korea").order_by('signup_date) * write in python * Django Translates to SQL :: Run 1. Create data base > CREATE DATABASE {data base name} 2. runserver > pipenv shell > python manage.py runse..
INSTALL PACKAGES and Setting :: Install > pipenv --three > pipenv shell > pipenv install -r requirements/local.txt :: Files local.txt base.txt :: Setting config L settings L base.py L local.py L production.py base.py, local.py => Run on Application production.py => Run on Server
CookieCutter - create django project - can customize django project :: Install > pip install cookiecutter :: clone > cookiecutter url >> project name >> author name >> email >> description >> domain name >> version >> timezone : Asia/Seoul >> white noise n >> celery n >> mailhog n >> sentry for error reporting n >> opbeat n >> pycham n >> windows n >> docker n >> heroku n >> elastic beanstalk experimental n ..
Parts of Django - Settings > Change the default set of Django > Install modules > remove modules - Urls > get Url > execute a view function - Apps > Components, Functions > CRUD
Virtual Environments :: Exp - Set Environments separately. on single system. - make separate bubble(space) - avoid global dependencies. - using different environment, version, dependencies :: Apps - Virtualenv - Virtualenvwrapper - Pipenv :: Install pipenv - terminal - project dir > pipenv --three > pipenv install django :: run djando-admin > pipenv shell > django-admin :: File > Pipfile [[source]] ... [packages] ....
Python Basic 2 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 12..