Coder Social home page Coder Social logo

quiz_beck_django's Introduction

Django 설치 및 코드작성

  • venv 설치

    • python3 -m venv venv
    • ls (venv 폴더 생성 확인)
  • venv 활성화

    • source venv/bin/activate
  • Django, djangorestframework 설치

    • pip install django djangorestframework
  • django project 생성

    • django-admin startproject myapi .
  • App 생성

    • python manage.py startapp quiz
  • vscode open

  • settings.py

    • ALLOWED_HOSTS = ['*'] // 모두허용
    • TIME_ZONE = 'Asia/Seoul'
    • STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') // 제일 마지막에 추가(정적파일관리)
    • INSTALLED_APPS = ['quiz','rest_framework',] // 추가
  • django migration

    • python manage.py makemigrations
    • python manage.py migrate
  • 기동

    • python manage.py runserver
  • 관리자계정 생성

    • python manage.py createsuperuser
  • models.py 작성

  • serializers.py 작성// serializer는 장고 모델 데이트럴 json 타입으로 바꿔주는 직렬화 기능

  • view.py 작성

Django 배포(heroku)

  • package 설치

    • pip install django-cors-headers gunicorn psycopg2-binary whitenoise dj-database-url
      • django-cors-headers : cors 에러 방지
      • gunicorn : 배포
      • psycopg2-binary : heroku에서 사용하는 DB postgressql을 위함
      • white noise : 정적 파일의 사용을 돕는 미들웨어
  • settings.py

    • SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY', 'key value')
      • DEBUG = False
      • MIDDLEWARE = ['whitenoise.middleware.WhiteNoiseMiddleware'] 추가
      • db_from_env = dj_database_url.config(conn_max_age=500)
        DATABASES['default'].update(db_from_env) // databases 하단 추가
  • Procfile 추가

  • runtime.txt 추가

  • .gitignore 추가

  • heroku CLI 환경 설치

    • brew install heroku/brew/heroku
  • heroku 로그인

    • heroku login
  • pjt 생성

    • heroku create drf-quiz-test(pjt name)
  • git 추가

    • git push heroku main
  • maigration

    • heroku run python manage.py migrate
  • super user 생성

    • heroku run python manage.py createsuperuser
  • 서버 기동

    • heroku open

quiz_beck_django's People

Contributors

lhs7091 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.