I decided to make a web application with python and summarized the procedure. I will update it from time to time. (MacOS Sierra ver10.12.4)
https://www.python.org/downloads/
http://uxmilk.jp/12691
http://www.sejuku.net/blog/28235
http://qiita.com/astronaughts/items/2cc6e8f18290e18a742d
↓ It seems that you are going to see the MacOS standard Python library, so put it in your PATH
sudo ln -s /Library/Frameworks/Python.framework/Versions/2.7/bin/django-admin.py /usr/local/bin/
If you do not do this, you will be asked to enter the password each time you save the py file, or you will not be able to add the file.
sudo chmod +x /usr/local/bin/django-admin.py
** Supplement ** How to open / usr / local / (mac) http://qiita.com/DarkLight_0/items/d257d4b8f27ad670f40d
django-admin startproject mySite
python manage.py startapp myapp(Make it with a different name from mySite)
Refer to "Creating a Polls application". .. .. https://docs.djangoproject.com/ja/1.11/intro/tutorial01/
http://qiita.com/griffin3104/items/c7908359a3e3e18cd269
http://qiita.com/aeas44/items/90c867aa2d02f9047ef0
Describe the model like this
myapp/models.py
from django.db import models
class Question(models.Model):
question_text = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
Then execute ↓ Save model changes in migration form (save to file on disk)
python manage.py makemigrations myapp
Check what SQL the migration executes (only if you want to check)
python manage.py sqlmigrate polls 0001
Create a model table in the database
python manage.py migrate
SyntaxError: Non-ASCII character '\xe3' It can be fixed by writing "# coding: utf-8" at the beginning of the executable file.
I wanted to find out the port number used by MySQL. .. .. http://qiita.com/yokozawa/items/dbcb3b31f9308e4dcefc
sudo lsof -i -P | grep "LISTEN"
Recommended Posts