restful
-
[Django] REST API (4) - Frontend 연동Phthon/Django 2020. 1. 1. 14:21
1. React 앱 작성 npm을 사용하기 위햐서는 Node.js 설치가 필요 https://nodejs.org/en/download/ Download | Node.js Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine. nodejs.org # prompt npm -v //설치 확인 npm install -g yarn //yarn 설치 yarn --version //yarn 설치 확인 npm install -g create-react-app //react app을 만들어주는 패키지 설치 //cd로 작업할 디렉토리로 이동후 create-react-app frontend //react app 생성 cd frontend yarn s..
-
[Django] Django REST API (3) - REST API CRUDPhthon/Django 2019. 12. 28. 21:35
1. R(Post List) # restful/serializers.py from rest_framework import serializers from .models import posts class postsListSerializer(serializers.ModelSerializer): class Meta: model = posts #모델 설정 fields = ('id', 'title', 'content', 'writer') #필드 설정 restful/views.py from rest_framework import generics from .serializers import * from .models import posts class postsList(generics.ListAPIView): query..
-
[Django] Django REST API (2) - REST API 작성Phthon/Django 2019. 12. 26. 20:27
1. Model 생성 #/restful/models.py from django.db import models class posts(models.Model): title = models.CharField(max_length=100) content = models.CharField(max_length=300) writer = models.CharField(max_length=100) def __str__(self): return self.title python manage.py makemigrations python manage.py migrate 2. Serializer 생성 /restful/serializers.py from rest_framework import serializers from .mode..
-
[Django] Django REST API (1) - 개발환경 설정Phthon/Django 2019. 12. 26. 19:45
0. 가상환경 설정 python -m venv venv venv\Scripts\activate 1. pip 최신버전인지 확인 python -m pip install --upgrade pip 2. Django 설치 pip install django~=2.0.0 3. Django 프로젝트 생성 django-admin.py startproject restStudy . 4. 설정 변경 restStudy/settings.py TIME_ZONE = 'Asia/Seoul' STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static') ALLOWED_HOSTS = ['127.0.0.1', '.pythonanywhere.com'] 5. DB 설정 pip i..