Django Getting Started: 1_Environment Building Django Getting Started: 2_Project Creation Beginning with Django: 3_Apache integration Beginning with Django: 4_MySQL integration
Last time we proceeded to build the environment, so this time we will actually create a project. It's 100 times more useful to refer to the official tutorial than to summarize it.
I will summarize it for beginners like myself who find it difficult even with a formal polite explanation.
Django has the concept of projects and applications. Roughly speaking, there are a number of applications in the project.
A project is the biggest concept, whether it's a site or system you want to create with Django. An application is a small feature (such as an article posting or voting system) within the site.
It seems that the smaller the particle size of the application, the better. Shred as much as possible and dedicate each application to one task. Loosely connect applications (do not depend on each other).
It seems that this makes it easy to divert the application to another project.
So anyway, start by creating a project. Go to the appropriate dictator (make / home / django or something).
django-admin startproject PROJECT_NAME
Enter your favorite project name in PROJECT_NAME. However, avoid names that python might import, such as test and django, as they will batting. Also, it seems to avoid the apache document root as the place to create it.
Now, let's check it on the simple server for development (this one cannot be used for public use, it is for development only).
cd PROJECT_NAME
python manage.py runserver 0.0.0.0:8000
Become a Vagrant and access port 8000 of the IP address of the server running Django with your browser. http://192.168.0.2:8000 With a feeling. Or wget --spider -S localhost: 8000
Vagrant or the server running Django and the accessing PC are different It says DisallowedHost at ...
Add an authorized host to settings.py. Let's open it in an editor. This time, I will allow all of them for the time being.
ALLOWED_HOSTS = ['*']
If you access the browser again and the message "It worked!" Is displayed, it is successful.
Now, with this, we will continue to create applications and add various functions, but next time we will set up the DB and web server first. The hard things are limited to getting rid of them first.
Create your first Django app ALLOWED_HOSTS must be set in Django 1.5 and above
Recommended Posts