- Learning Website Development with Django
- Ayman Hourieh
- 229字
- 2021-07-02 11:41:17
Summary
In this chapter, we learned about the three main components of Django: the view, model and template. We wrote data models to store the data of our application, and then created views and templates to display this data. We also learned how to map URLs to views, and how to use the interactive console to experiment with our Django project.
Below is a summary of the Django features covered in this chapter:
- To create an application within a project, run the following command:
$ python manage.py startapp <app-name>
- After writing a data model, the following command should be run to create the corresponding tables in the database:
$ python manage.py syncdb
- To view the SQL queries generated by Django, issue the following command:
$ python manage.py sql <app-name>
- Data models provide a variety of methods to interact with the database engine:
- The
save
method saves an object into the database. - The
objects.get
method retrieves an object by a unique field. - The
objects.all
method retrieves a list of all objects. - The
delete
method deletes an object from the database.
- The
- To generate a 404 "Page Not Found" error, raise an exception of type type
Http404
.
In the next chapter, we will continue developing our application, but we will focus mostly on user management features, such as registration and logging in. The next chapter provides a lot of useful information, so read on!
推薦閱讀
- Premiere Pro 2022從新手到高手
- Authorware應用案例教程
- 音樂日記:Logic Pro X場景x風格編曲實用教程
- 專業級音樂制作理論與實踐Pro Tools:從入門到應用
- 量化投資與FOF投資:以MATLAB+Python為工具
- 中文版After Effects CC 2018 動漫、影視特效后期合成秘技
- Magento: Beginner's Guide
- 24小時玩賺剪映
- Flash CS6 動畫制作實戰從入門到精通
- Building Websites with Mambo
- AutoCAD 2010 機械設計與制作技能基礎教程
- Sage ACT! 2012 Cookbook
- Photoshop CC 2015課堂實錄
- 零基礎學Revit 2018建筑設計(全視頻教學版)
- PHPList 2 E/mail Campaign Manager