Let's make a nervous breakdown app with Vue.js and Django-Rest-Framework [Part 1] ~ Django setup ~

Part 2 >>

version information

OS:MacOS X node:v12.14.1 npm:6.13.4 @vue/cli:4.1.2 python:3.7.4 Django:2.2.6 django-rest-framework:0.1.0

Creating a virtual environment for Python

Advance preparation

See here to be able to do the following: ・ Pyenv can be used -You can create a Python virtual environment with pyenv-virtualenv

Create virtual environment

Create a virtual environment for python 3.7.4. The name is "concentratio" because it causes nervous breakdown.

butterthon$ pyenv virtualenv 3.7.4 concentratio

That's all for creating a virtual environment.

Create a Django project

Advance preparation

Create a project root directory and apply the virtual environment.

butterthon$ mkdir workspace #Prepare a workspace
butterthon$ cd workspace
workspace$ mkdir concentratio #Create application root directory in workspace (name is arbitrary)
workspace$ cd concentratio
concentratio $ pyenv local concentratio
(concentratio)concentratio$ python -V
Python 3.7.4

Project creation

concentratio$ django-admin startproject config .

It has the following configuration.

concentratio #Project root directory
├── config #Configuration files are organized under config
│   ├── __init__.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
└── manage.py

Check the Django startup screen.

Start the Django server with ` python3 manage.py runserver ` and access [http: // localhost: 8000](http: // localhost: 8000).

(concentratio)concentratio$ python3 manage.py runserver #Start Django server


Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).

You have 17 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.

January 08, 2020 - 15:35:47
Django version 2.2.6, using settings 'config.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

It's OK if the screen where the rocket is launching is displayed! !! !!

Install Django Rest Framework

(concentratio)concentratio$ pip install django-rest-framework

After installation, add it to the configuration file.

config/settings.py


.
..
...
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'rest_framework', #add to
]
...
..
.

List API endpoints

config/urls.py


.
..
...
from django.contrib import admin
from django.urls import path
from django.conf.urls import include, url #add to
from rest_framework import routers #add to

ROUTER = routers.DefaultRouter() #add to

urlpatterns = [
    path('admin/', admin.site.urls),
    url('api/', include(ROUTER.urls)), #add to
]

Check if the Django Rest Framework can be started correctly by accessing [http: // localhost: 8000 / api](http: // localhost: 8000 / api) image.png

Part 2 >>

Recommended Posts

Let's make a nervous breakdown app with Vue.js and Django-Rest-Framework [Part 1] ~ Django setup ~
Let's make a nervous breakdown application with Vue.js and Django-Rest-Framework [Part 3] ~ Implementation of nervous breakdown ~
Let's make a nervous breakdown application with Vue.js and Django-Rest-Framework [Part 6] ~ User Authentication 2 ~
Let's make a nervous breakdown application with Vue.js and Django-Rest-Framework [Part 5] ~ User authentication ~
Try to make a nervous breakdown application with Vue.js and Django-Rest-Framework [Part 4] ~ MySQL construction and DB migration with Docker ~
Let's make a Mac app with Tkinter and py2app
Make a scraping app with Python + Django + AWS and change jobs
Let's make a simple game with Python 3 and iPhone
Let's make an app that can search similar images with Python and Flask Part1
Let's make an app that can search similar images with Python and Flask Part2
Build a bulletin board app from scratch with Django. (Part 2)
Build a bulletin board app from scratch with Django. (Part 3)
Let's make a GUI with python.
Let's make a breakout with wxPython
Make a filter with a django template
Let's make a graph with python! !!
Let's make a supercomputer with xCAT
Let's make a WEB application for phone book with flask Part 1
Let's make a WEB application for phone book with flask Part 2
Make a thermometer with Raspberry Pi and make it viewable with a browser Part 4
Let's make a WEB application for phone book with flask Part 3
Let's make a WEB application for phone book with flask Part 4
Let's make a shiritori game with Python
Let's make a voice slowly with Python
Let's make a simple language with PLY 1
Let's make a web framework with Python! (1)
Let's make a tic-tac-toe AI with Pylearn 2
Create a Todo app with Django ④ Implement folder and task creation functions
Make a desktop app with Python with Electron
Let's make a Twitter Bot with Python!
Let's make a web framework with Python! (2)
Make a thermometer with Raspberry Pi and make it visible on the browser Part 3
Try creating a web application with Vue.js and Django (Mac)-(1) Environment construction, application creation
How to develop a cart app with Django
Let's replace UWSC with Python (5) Let's make a Robot
Create a Todo app with Django REST Framework + Angular
Create a native GUI app with Py2app and Tkinter
[Practice] Make a Watson app with Python! # 2 [Translation function]
[Practice] Make a Watson app with Python! # 1 [Language discrimination]
[Let's play with Python] Make a household account book
How to make a shooting game with toio (Part 1)
Create a Todo app with the Django REST framework
Create a Todo app with Django ③ Create a task list page
Let's make dependency management with pip a little easier
Let's make a spherical grid with Rhinoceros / Grasshopper / GHPython
Deploy a Django app made with PTVS on Azure
Create a Todo app with Django ⑤ Create a task editing function
[Super easy] Let's make a LINE BOT with Python.
When I deploy a Django app with Apache2 and it no longer reads static files
Let's make a websocket client with Python. (Access token authentication)
[Practice] Make a Watson app with Python! # 3 [Natural language classification]
Make a tky2jgd plugin with no practicality in QGIS Part 2
Associate Python Enum with a function and make it Callable
I want to make a blog editor with django admin
Let's create a PRML diagram with Python, Numpy and matplotlib.
Make a tky2jgd plugin with no practicality in QGIS Part 1
Make a Mac menu bar resident weather app with rumps!
Make a 2D RPG with Ren'Py (3) -Items and Tool Shop
Create a Todo app with Django ① Build an environment with Docker
Let's make a diagram that can be clicked with IPython
Make a BLE thermometer and get the temperature with Pythonista3