
上QQ阅读APP看书,第一时间看更新
Getting ready
You can create a Django app in one of three ways:
- Generate all of the files manually, which can be an excellent tool for learning, but is far from the most efficient approach.
- Use the startapp command in your virtual environment, as follows:
(myproject_env)$ django-admin.py startapp magazine
Learn how to use virtual environments in the Working with a virtual environment and Creating a virtual environment project file structure recipes.
- Use the startapp command in a Docker project, as follows:
myproject_django/$ docker-compose run app django-admin.py startapp magazine
Learn how to use Docker in the Working with Docker and Creating a Docker project file structure recipes.
With your magazine app created, add a NewsArticle model to models.py, create administration for the model in admin.py, and put "magazine" in INSTALLED_APPS in the settings.py. If you are not yet familiar with these tasks, study the official Django tutorial at:
https://docs.djangoproject.com/en/2.1/intro/tutorial01/.