[PYTHON] Django Learning Memo

background

Start learning Django to learn python and web applications. Make a note of frequently used commands and what you noticed during development.

Reference page

http://docs.djangoproject.jp/en/latest/intro/tutorial01.html

Environmental preparation

environment

CentOS : 6.5 python : 2.6.6 django: 1.6 (I got an error when I installed the latest 1.9. Maybe it's compatible with the python version? To get an overview of the framework, I used the old version that worked with 2.6)

Installation

$ pip install django==1.6


 Installation is successful if no error occurs with the following command
``` $ python ```
``` >>> import django ```
``` >>> quit() ```

# Development project creation
## Start the project
 After moving to the working directory, the development directory is created with the following command.

#### **` $ django-admin.py startproject test `**
```py startproject test 

$ ll test ```

## Database settings
 Edit the contents of test / settings.py and execute the following command.
 Main editing points
 --ENGINE: DBMS to use (django.db.backends.sqlite3 etc.)
 --INSTALLED_APPS: Application to install


#### **` $ python manage.py syncdb `**
```py syncdb 

 Create the required DB for INSTALLED_APPS.

## Start the server
 You can start the server by specifying the IP and port

#### **` $ python manage.py runserver 0.0.0.0:8000 `**

If not specified, the default is 127.0.0.1:8000

application development

Start development

Execute the following command in the working directory.

$ python manage.py startapp polls


 The following files are created
    __init__.py
    admin.py
    models.py
    tests.py
    views.py

## Model design
 --Edit models.py to design the table required for your application.
 --Register the designed application in INATALLED_APPS in setting.py
 --Check the registered SQL with python manage.py sql polls
 --Reflected in DB

## Frequently used items on the Admin page
File : Application_Dir/admin.py
 --admin.site.register (Poll, PollAdmin): Register so that it can be edited from the Admin screen, and define detailed settings in another class (Ex: PollAdmin)

File : Project_Dir/setting.py
 --TEMPLATE_DIRS: Specify the template storage to set the look and feel. Default is under django / contrib / admin / templates / admin


Recommended Posts

Django Learning Memo
[Learning memo] Django command summary
LPIC201 learning memo
django tutorial memo
[Memo] Machine learning
Python class (Python learning memo ⑦)
Python module (Python learning memo ④)
heroku deployment memo (Django)
Django memo # 1 from scratch
Machine learning course memo
[Memo] Django development environment
Python exception handling (Python learning memo ⑥)
Django development environment construction memo
Django
Practical machine learning system memo
Supervised learning ~ Beginner's memo ~ (scikit-learn)
Python control syntax, functions (Python learning memo ②)
Django admin screen reverse lookup memo
Deep Learning / Deep Learning from Zero 2 Chapter 4 Memo
Deep Learning / Deep Learning from Zero Chapter 3 Memo
Deep Learning / Deep Learning from Zero 2 Chapter 5 Memo
[Django memo] Failure when installing modal
Input / output with Python (Python learning memo ⑤)
DJango Memo: From the beginning (preparation)
Linux command [ldconfig] LPIC learning memo
Deep Learning / Deep Learning from Zero 2 Chapter 7 Memo
Deep Learning / Deep Learning from Zero 2 Chapter 8 Memo
Interval scheduling learning memo ~ by python ~
Deep Learning / Deep Learning from Zero Chapter 5 Memo
Deep Learning / Deep Learning from Zero Chapter 4 Memo
Deep Learning / Deep Learning from Zero 2 Chapter 3 Memo
"Scraping & machine learning with Python" Learning memo
Deep Learning / Deep Learning from Zero 2 Chapter 6 Memo
real-time-Personal-estimation (learning)
gzip memo
Raspberry-pi memo
Python & Machine Learning Study Memo: Environment Preparation
django update
Django note 4
Pandas memo
Memorandum / memo about programming learning / competitive programming site
DJango Memo: From the beginning (model settings)
Django memorandum
django search
HackerRank memo
Django installation
Python numbers, strings, list types (Python learning memo ①)
Python memo
[Learning memo] Basics of class by python
[Learning memo] Deep Learning made from scratch [Chapter 7]
Django Summary
Django test
python memo
Information recording memo using session in Django
graphene memo
Flask memo
pyenv memo
Matplotlib memo
Learning record
pytest memo
sed memo