Start learning Django to learn python and web applications. Make a note of frequently used commands and what you noticed during development.
http://docs.djangoproject.jp/en/latest/intro/tutorial01.html
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)
$ 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
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