- Django 2 by Example
- Antonio Melé
- 168字
- 2021-06-25 21:18:59
Creating an application
Now, let's create our first Django application. We will create a blog application from scratch. From the project's root directory, run the following command:
python manage.py startapp blog
This will create the basic structure of the application, which looks like this:
blog/
__init__.py
admin.py
apps.py
migrations/
__init__.py
models.py
tests.py
views.py
These files are as follows:
- admin.py: This is where you register models to include them in the Django administration site—using the Django admin site is optional.
- apps.py: This includes the main configuration of the blog application.
- migrations: This directory will contain database migrations of your application. Migrations allow Django to track your model changes and synchronize the database accordingly.
- models.py: Data models of your application—all Django applications need to have a models.py file, but this file can be left empty.
- tests.py: This is where you can add tests for your application.
- views.py: The logic of your application goes here; each view receives an HTTP request, processes it, and returns a response.
推薦閱讀
- 網(wǎng)絡(luò)云百問百答
- 物聯(lián)網(wǎng)智慧安監(jiān)技術(shù)
- 智慧城市中的移動(dòng)互聯(lián)網(wǎng)技術(shù)
- Drush User’s Guide
- 網(wǎng)絡(luò)的琴弦:玩轉(zhuǎn)IP看監(jiān)控
- Microsoft Dynamics CRM 2011 Applications(MB2-868) Certification Guide
- 物聯(lián)網(wǎng)長距離無線通信技術(shù)應(yīng)用與開發(fā)
- Windows Server 2012 Hyper-V虛擬化管理實(shí)踐
- Echo Quick Start Guide
- 4G小基站系統(tǒng)原理、組網(wǎng)及應(yīng)用
- Learning Windows 8 Game Development
- 深入理解OpenStack Neutron
- 移動(dòng)物聯(lián)網(wǎng):商業(yè)模式+案例分析+應(yīng)用實(shí)戰(zhàn)
- 中國互聯(lián)網(wǎng)發(fā)展報(bào)告2021
- 圖神經(jīng)網(wǎng)絡(luò)前沿