当前位置: 首页 > 工具软件 > documentation > 使用案例 >

Django documentation

百里诚
2023-12-01


趁着这个假期我把 Django的官网文档整理了一下,这其中不包括太多的代码案例,只是把常用的知识点、核心内容和开发常见的问题汇总一下。主要针对新手、开发人员使用(看过源码的大佬请忽略)。

入门秘笈

官方文档带你入门Djangohttps://docs.djangoproject.com/en/3.1/intro/,这部分文档介绍挺详细,而且对于新手没有太大的难度,易于理解,代码完整

下面是我总结的一些知识点,这些内容也包含在官方文档中,但这是我认为新手可能经常忽略的部分。

Django应用创建和文件夹的含义

https://docs.djangoproject.com/en/3.1/intro/tutorial01/

Django中的自动化测试

https://docs.djangoproject.com/en/3.1/intro/tutorial05/
创建测试类—test.py
应用程序测试的常规位置是在应用程序的 tests.py文件中。测试系统将自动在其中找对应的测试类

import datetime

from django.test import TestCase
from django.utils import timezone

from .models import Question


class QuestionModelTests(TestCase):

    def test_was_published_recently_with_future_question(self):
        """
        was_published_recently() returns False for questions whose pub_date
        is in the future.
        """
        time = timezone.now() + datetime.timedelta(days=30)
        future_question = Question(pub_date=time)
        self.assertIs(future_question.was_published_recently(), False)
    def test_was_published_recently_with_old_question(self):
    """
    was_published_recently() returns False for questions whose pub_date
    is older than 1 day.
    """
    time = timezone.now() - datetime.timedelta(days=1, seconds=1)
    old_question = Question(pub_date=time)
    self.assertIs(old_question.was_published_recently(), False)

`

运行测试

python manage.py test app名称

将Django项目打包成应用程序

https://docs.djangoproject.com/en/3.1/intro/reusable-apps/

为Django提供补丁

https://docs.djangoproject.com/en/3.1/intro/contributing/

使用手册

安装Django

https://docs.djangoproject.com/en/3.1/topics/install/

模型和数据库

https://docs.djangoproject.com/en/3.1/topics/db/

多数据的使用: https://docs.djangoproject.com/en/3.1/topics/db/multi-db/

Http请求

https://docs.djangoproject.com/en/3.1/topics/http/

中间件: https://docs.djangoproject.com/en/3.1/topics/http/middleware/

基于类的视图

https://docs.djangoproject.com/en/3.1/topics/class-based-views/

表单

https://docs.djangoproject.com/en/3.1/topics/forms/

模板

https://docs.djangoproject.com/en/3.1/topics/templates/

迁移相关

https://docs.djangoproject.com/en/3.1/topics/migrations/

测试

https://docs.djangoproject.com/en/3.1/topics/testing/

处理邮件

https://docs.djangoproject.com/en/3.1/topics/email/

本地化和国际化

https://docs.djangoproject.com/en/3.1/topics/i18n/

常见问题汇总

https://docs.djangoproject.com/en/3.1/faq/

API

https://docs.djangoproject.com/en/3.1/ref/

索引

https://docs.djangoproject.com/en/3.1/py-modindex/

 类似资料:

相关阅读

相关文章

相关问答