[Django Rest Framework] #1

현지수·2022년 8월 25일
0

유튜브 참고 영상

✨ Django 프로젝트 생성

  • django-admin startproject rest-youtube-project
  • django-admin startapp student
  • student 앱 내부에 model 클래스를 구성하기(models.py)
from django.db import models

# Create your models here.
class Student(models.Model):
    student_id = models.CharField(max_length=15, unique=True)
    name = models.CharField(max_length=30)
    age = models.IntegerField()
  • settings.py에 student 앱 등록하기
  • python manage.py makemigrations
  • python manage.py migrate
  • 로컬 서버에 임의로 데이터를 추가하기 위해 Student 클래스 등록(student/admin.py)
from django.contrib import admin
from .models import Student

# Register your models here.

admin.site.register(Student)
  • 이제 로컬 서버로 들어가서 관리자 페이지를 보면 Student 데이터를 추가할 수 있다

여기까지는 매우매우 간단한 기본 프로젝트 생성이라 어려운게 없었따
velog때문에 처음으로 마크다운 언어를 써보았다! 우왕

profile
두두

0개의 댓글