1. Project VS Application
What is the difference between project and application?
A project is a collection of configurations and applications used by a website.
An application is a web application dedicated to doing something -- like a blogging system, or a database of public records, or a simple voting program.
A project can contain many applications.
Applications can be used by many projects.
2.Django2.0 connects to MySQL database
After all kinds of thunder
I also don't know which step is the key factor
step1: uninstall python 32 bit
step2: install python 64 bit
step3:pip install PyMySQL
step4:pip install mysqlclient
step5: Modify settings.py
INSTALLED_APPS = [
'polls.apps.PollsConfig','django.contrib.admin','django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles',]
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'supermarket', 'USER': 'root', 'PASSWORD': 'password', 'Host': 'localhost', 'PORT': '3306', } }
step6: Modify the models.py file
from django.db import models class Question(models.Model): question_text = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') class Choice(models.Model): question = models.ForeignKey(Question, on_delete=models.CASCADE) choice_text = models.CharField(max_length=200) votes = models.IntegerField(default=0)
step7: Execute python manage.py makemigrations
step8: Execute python manage.py migrate