{"id":26579,"date":"2022-11-21T00:59:59","date_gmt":"2022-11-20T16:59:59","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=26579"},"modified":"2022-11-21T01:00:39","modified_gmt":"2022-11-20T17:00:39","slug":"source-django-package","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/source-django-package.html","title":{"rendered":"5 \u4e2a\u6700\u53d7\u4eba\u559c\u7231\u7684\u5f00\u6e90 Django \u5305"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nDjango \u56f4\u7ed5\u201c\u53ef\u91cd\u7528\u5e94\u7528\u201d\u7684\u601d\u60f3\u5efa\u7acb\uff1a\u81ea\u5305\u542b\u7684\u5305\u63d0\u4f9b\u4e86\u53ef\u91cd\u590d\u4f7f\u7528\u7684\u7279\u6027\u3002\u4f60\u53ef\u4ee5\u5c06\u8fd9\u4e9b\u53ef\u91cd\u7528\u5e94\u7528\u7ec4\u88c5\u8d77\u6765\uff0c\u5728\u52a0\u4e0a\u9002\u7528\u4e8e\u4f60\u7684\u7f51\u7ad9\u7684\u7279\u5b9a\u4ee3\u7801\uff0c\u6765\u642d\u5efa\u4f60\u81ea\u5df1\u7684\u7f51\u7ad9\u3002Django \u5177\u6709\u4e00\u4e2a\u4e30\u5bcc\u591a\u6837\u7684\u3001\u7531\u53ef\u4f9b\u4f60\u4f7f\u7528\u7684\u53ef\u91cd\u7528\u5e94\u7528\u7ec4\u5efa\u8d77\u6765\u7684\u751f\u6001\u7cfb\u7edf\u2014\u2014PyPI \u5217\u51fa\u4e86\u8d85\u8fc7 8000\u4e2a Django \u5e94\u7528\u2014\u2014\u53ef\u4f60\u8be5\u5982\u4f55\u77e5\u9053\u54ea\u4e9b\u662f\u6700\u597d\u7684\u5462\uff1f<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"source-django-package\"<\/p>\n

\u4e3a\u4e86\u8282\u7701\u4f60\u7684\u65f6\u95f4\uff0c\u6211\u4eec\u603b\u7ed3\u4e86\u4e94\u4e2a\u6700\u53d7\u559c\u7231\u7684 Django \u5e94\u7528\u3002\u5b83\u4eec\u662f\uff1a<\/p>\n

    \n
  1. Cookiecutter: \u5efa\u7acb Django \u7f51\u7ad9\u7684\u6700\u4f73\u65b9\u5f0f\u3002<\/li>\n
  2. Whitenoise: \u6700\u68d2\u7684\u9759\u6001\u8d44\u6e90\u670d\u52a1\u5668\u3002<\/li>\n
  3. Django Rest Framework: \u4f7f\u7528 Django \u5f00\u53d1 REST API \u7684\u6700\u4f73\u65b9\u5f0f\u3002<\/li>\n
  4. Wagtail: \u57fa\u4e8e Django \u7684\u6700\u4f73\u5185\u5bb9\u7ba1\u7406\u7cfb\u7edf\uff08CMS\uff09\u3002<\/li>\n
  5. django-allauth: \u63d0\u4f9b\u793e\u4ea4\u8d26\u6237\u767b\u5f55\u7684\u6700\u4f73\u5e94\u7528\uff08\u5982 Twitter, Facebook, GitHub \u7b49\uff09\u3002<\/li>\n<\/ol>\n

    \u6211\u4eec\u540c\u6837\u63a8\u8350\u4f60\u770b\u770b Django Packages\uff0c\u8fd9\u662f\u4e00\u4e2a\u53ef\u91cd\u7528 Django \u5e94\u7528\u7684\u76ee\u5f55\u3002Django Packages \u5c06 Django \u5e94\u7528\u7ec4\u7ec7\u6210\u201c\u8868\u683c\u201d\uff0c\u4f60\u53ef\u4ee5\u5728\u529f\u80fd\u76f8\u4f3c\u7684\u4e0d\u540c\u5e94\u7528\u4e4b\u95f4\u8fdb\u884c\u6bd4\u8f83\u5e76\u505a\u51fa\u9009\u62e9\u3002\u4f60\u53ef\u4ee5\u67e5\u770b\u6bcf\u4e2a\u5305\u4e2d\u63d0\u4f9b\u7684\u7279\u6027\u548c\u4f7f\u7528\u7edf\u8ba1\u60c5\u51b5\u3002\uff08\u6bd4\u5982\uff1a\u8fd9\u662f REST \u5de5\u5177\u7684\u8868\u683c\uff0c\u4e5f\u8bb8\u53ef\u4ee5\u5e2e\u52a9\u4f60\u7406\u89e3\u6211\u4eec\u4e3a\u4f55\u63a8\u8350 Django REST Framework\u3002<\/p>\n

    \u4e3a\u4ec0\u4e48\u4f60\u5e94\u8be5\u76f8\u4fe1\u6211\u4eec\uff1f<\/strong><\/div>\n

    \u6211\u4eec\u4f7f\u7528 Django \u7684\u65f6\u95f4\u51e0\u4e4e\u6bd4\u4efb\u4f55\u4eba\u90fd\u957f\u3002\u5728 Django \u53d1\u5e03\u4e4b\u524d\uff0c\u6211\u4eec\u5f53\u4e2d\u7684\u4e24\u4e2a\u4eba\uff08Frank \u548c Jacob\uff09\u5c31\u5728 Lawrence Journal-World \uff08Django \u7684\u53d1\u6e90\u5730\uff09\u5de5\u4f5c\uff08\u4e8b\u5b9e\u4e0a\uff0c\u662f\u4ed6\u4eec\u4e24\u4eba\u63a8\u52a8\u4e86 Django \u5f00\u6e90\u53d1\u5e03\u7684\u8fdb\u7a0b\uff09\u3002\u6211\u4eec\u5728\u8fc7\u53bb\u7684\u516b\u5e74\u5f53\u4e2d\u8fd0\u884c\u7740\u4e00\u4e2a\u54a8\u8be2\u516c\u53f8\uff0c\u6765\u5efa\u8bae\u516c\u53f8\u600e\u6837\u6700\u597d\u5730\u5e94\u7528 Django\u3002<\/p>\n

    \u6240\u4ee5\uff0c\u6211\u4eec\u89c1\u8bc1\u4e86 Django \u9879\u76ee\u548c\u793e\u7fa4\u7684\u5b8c\u6574\u5386\u53f2\uff0c\u6211\u4eec\u89c1\u8bc1\u4e86\u90a3\u4e9b\u6d41\u884c\u7684\u8f6f\u4ef6\u5305\u7684\u5174\u8d77\u548c\u6ca1\u843d\u3002\u5728\u6211\u4eec\u4e09\u4e2a\u4e4b\u4e2d\uff0c\u6211\u4eec\u4e2a\u4eba\u53ef\u80fd\u8bd5\u7528\u4e86 8000 \u4e2a\u5e94\u7528\u4e2d\u81f3\u5c11\u4e00\u534a\u4ee5\u4e0a\uff0c\u6216\u8005\u6211\u4eec\u77e5\u9053\u8c01\u8bd5\u7528\u8fc7\u8fd9\u4e9b\u3002\u6211\u4eec\u5bf9\u5982\u4f55\u4f7f\u5e94\u7528\u53d8\u5f97\u575a\u5b9e\u53ef\u9760\u6709\u7740\u6df1\u523b\u7684\u7406\u89e3\uff0c\u5e76\u4e14\u6211\u4eec\u5bf9\u7ed9\u4e88\u8fd9\u4e9b\u5e94\u7528\u6301\u4e45\u529b\u91cf\u7684\u6765\u6e90\u4e5f\u6709\u7740\u6df1\u5165\u7684\u4e86\u89e3\u3002<\/p>\n

    \u5efa\u7acb Django \u7f51\u7ad9\u7684\u6700\u4f73\u65b9\u5f0f\uff1a<\/strong><\/div>\n

    \u5efa\u7acb\u4e00\u4e2a\u65b0\u9879\u76ee\u6216\u5e94\u7528\u603b\u662f\u6709\u4e9b\u75db\u82e6\u3002\u4f60\u53ef\u4ee5\u7528 Django \u5185\u5efa\u7684 <\/p>\n

    startproject<\/pre>\n

    \u4e0d\u8fc7\uff0c\u5982\u679c\u4f60\u50cf\u6211\u4eec\u4e00\u6837\uff0c\u5bf9\u5982\u4f55\u505a\u4e8b\u6bd4\u8f83\u6311\u5254\u3002Cookiecutter \u4e3a\u4f60\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5feb\u6377\u7b80\u5355\u7684\u65b9\u5f0f\u6765\u6784\u5efa\u9879\u76ee\u6216\u6613\u4e8e\u91cd\u7528\u7684\u5e94\u7528\u6a21\u677f\uff0c\u4ece\u800c\u89e3\u51b3\u4e86\u8fd9\u4e2a\u95ee\u9898\u3002\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff1a\u952e\u5165 <\/p>\n

    pip install cookiecutter<\/pre>\n

    \uff0c\u7136\u540e\u5728\u547d\u4ee4\u884c\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

    $ cookiecutter https:\/\/github.com\/marcofucci\/cookiecutter-simple-django\r\n<\/pre>\n

    \u63a5\u4e0b\u6765\u4f60\u9700\u8981\u56de\u7b54\u51e0\u4e2a\u7b80\u5355\u7684\u95ee\u9898\uff0c\u6bd4\u5982\u4f60\u7684\u9879\u76ee\u540d\u79f0\u3001\u76ee\u5f55\u3001\u4f5c\u8005\u540d\u5b57\u3001E-Mail \u548c\u5176\u4ed6\u51e0\u4e2a\u5173\u4e8e\u914d\u7f6e\u7684\u5c0f\u95ee\u9898\u3002\u8fd9\u4e9b\u80fd\u591f\u5e2e\u4f60\u8865\u5145\u9879\u76ee\u76f8\u5173\u7684\u7ec6\u8282\u3002\u6211\u4eec\u4f7f\u7528\u6700\u6700\u539f\u59cb\u7684 \u201cfoo<\/em>\u201d \u4f5c\u4e3a\u6211\u4eec\u7684\u76ee\u5f55\u540d\u79f0\u3002\u6240\u4ee5 cokkiecutter \u5728\u5b50\u76ee\u5f55 \u201cfoo<\/em>\u201d \u4e0b\u5efa\u7acb\u4e86\u4e00\u4e2a\u7b80\u5355\u7684 Django \u9879\u76ee\u3002<\/p>\n

    \u5982\u679c\u4f60\u5728 \u201cfoo<\/em>\u201d \u9879\u76ee\u4e2d\u95f2\u901b\uff0c\u4f60\u4f1a\u770b\u89c1\u4f60\u521a\u521a\u9009\u62e9\u7684\u5176\u5b83\u8bbe\u7f6e\u5df2\u901a\u8fc7\u6a21\u677f\uff0c\u8fde\u540c\u6240\u9700\u7684\u5b50\u76ee\u5f55\u4e00\u540c\u5d4c\u5165\u5230\u6587\u4ef6\u5f53\u4e2d\u3002\u8fd9\u4e2a\u201c\u6a21\u677f\u201d\u5728\u6211\u4eec\u521a\u521a\u5728\u6267\u884c <\/p>\n

    cookiecutter<\/pre>\n

    \u547d\u4ee4\u65f6\u8f93\u5165\u7684\u552f\u4e00\u4e00\u4e2a\u53c2\u6570 Github \u4ed3\u5e93 URL \u4e2d\u5b9a\u4e49\u3002\u8fd9\u4e2a\u6837\u4f8b\u5de5\u7a0b\u4f7f\u7528\u4e86\u4e00\u4e2a Github \u8fdc\u7a0b\u4ed3\u5e93\u4f5c\u4e3a\u6a21\u677f\uff1b\u4e0d\u8fc7\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528\u672c\u5730\u7684\u6a21\u677f\uff0c\u8fd9\u5728\u5efa\u7acb\u975e\u91cd\u7528\u9879\u76ee\u65f6\u975e\u5e38\u6709\u7528\u3002<\/p>\n

    \u6211\u4eec\u8ba4\u4e3a cookiecutter \u662f\u4e00\u4e2a\u6781\u68d2\u7684 Django \u5305\uff0c\u4f46\u662f\uff0c\u4e8b\u5b9e\u4e0a\u5176\u5b9e\u5b83\u5728\u9762\u5bf9\u7eaf Python \u751a\u81f3\u975e Python \u76f8\u5173\u9700\u6c42\u65f6\u4e5f\u6781\u4e3a\u6709\u7528\u3002\u4f60\u80fd\u591f\u5c06\u6240\u6709\u6587\u4ef6\u4ee5\u4e00\u79cd\u53ef\u91cd\u590d\u7684\u65b9\u5f0f\u7cbe\u786e\u5730\u6446\u653e\u5728\u4efb\u4f55\u4f4d\u7f6e\u4e0a\uff0c\u4f7f\u5f97 cookiecutter \u6210\u4e3a\u4e86\u4e00\u4e2a\u7b80\u5316\uff08DRY\uff09\u5de5\u4f5c\u6d41\u7a0b\u7684\u6781\u4f73\u5de5\u5177\u3002<\/p>\n

    \u6700\u68d2\u7684\u9759\u6001\u8d44\u6e90\u670d\u52a1\u5668\uff1aWhitenoise<\/strong><\/div>\n

    \u591a\u5e74\u6765\uff0c\u6258\u7ba1\u7f51\u7ad9\u7684\u9759\u6001\u8d44\u6e90\u2014\u2014\u56fe\u7247\u3001Javascript\u3001CSS\u2014\u2014\u90fd\u662f\u4e00\u4ef6\u5f88\u75db\u82e6\u7684\u4e8b\u60c5\u3002Django \u5185\u5efa\u7684 django.views.static.serve \u89c6\u56fe\uff0c\u5c31\u50cf Django \u6587\u7ae0\u6240\u8ff0\u7684\u90a3\u6837\uff0c\u201c\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u4e0d\u53ef\u9760\uff0c\u6240\u4ee5\u53ea\u5e94\u4e3a\u5f00\u53d1\u73af\u5883\u7684\u63d0\u4f9b\u8f85\u52a9\u529f\u80fd\u3002\u201d\u4f46\u4f7f\u7528\u4e00\u4e2a\u201c\u771f\u6b63\u7684\u201d Web \u670d\u52a1\u5668\uff0c\u5982 NGINX \u6216\u8005\u501f\u52a9 CDN \u6765\u6258\u7ba1\u5a92\u4f53\u8d44\u6e90\uff0c\u914d\u7f6e\u8d77\u6765\u4f1a\u6bd4\u8f83\u56f0\u96be\u3002<\/p>\n

    Whitenoice \u5f88\u7b80\u6d01\u5730\u89e3\u51b3\u4e86\u8fd9\u4e2a\u95ee\u9898\u3002\u5b83\u53ef\u4ee5\u50cf\u5728\u5f00\u53d1\u73af\u5883\u90a3\u6837\u8f7b\u6613\u5730\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u8bbe\u7f6e\u9759\u6001\u670d\u52a1\u5668\uff0c\u5e76\u4e14\u9488\u5bf9\u751f\u4ea7\u73af\u5883\u8fdb\u884c\u4e86\u52a0\u56fa\u548c\u4f18\u5316\u3002\u5b83\u7684\u8bbe\u7f6e\u65b9\u6cd5\u6781\u4e3a\u7b80\u5355\uff1a<\/p>\n

      \n
    1. \u786e\u4fdd\u4f60\u5728\u4f7f\u7528 Django \u7684 contrib.staticfiles \u5e94\u7528\uff0c\u5e76\u786e\u8ba4\u4f60\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u6b63\u786e\u8bbe\u7f6e\u4e86STATIC_ROOT \u53d8\u91cf\u3002<\/li>\n
    2. \u5728wsgi.py\u6587\u4ef6\u4e2d\u542f\u7528 Whitenoise:\n
      from django.core.wsgi import get_wsgi_application\r\nfrom whitenoise.django import DjangoWhiteNoise\r\n\r\napplication = get_wsgi_application()\r\napplication = DjangoWhiteNoise(application)\r\n><\/pre>\n<\/li>\n<\/ol>\n

      \u914d\u7f6e\u5b83\u771f\u7684\u5c31\u8fd9\u4e48\u7b80\u5355\uff01\u5bf9\u4e8e\u5927\u578b\u5e94\u7528\uff0c\u4f60\u53ef\u80fd\u60f3\u8981\u4f7f\u7528\u4e00\u4e2a\u4e13\u7528\u7684\u5a92\u4f53\u670d\u52a1\u5668\u548c\/\u6216\u4e00\u4e2a CDN\uff0c\u4f46\u5bf9\u4e8e\u5927\u591a\u6570\u5c0f\u578b\u6216\u4e2d\u578b Django \u7f51\u7ad9\uff0cWhitenoise \u5df2\u7ecf\u8db3\u591f\u5f3a\u5927\u3002<\/p>\n

      \u5982\u9700\u67e5\u770b\u66f4\u591a\u5173\u4e8e Whitenoise \u7684\u4fe1\u606f\uff0c\u8bf7\u67e5\u770b\u6587\u6863\u3002<\/p>\n

      \u5f00\u53d1 REST API \u7684\u6700\u4f73\u5de5\u5177\uff1aDjango REST Framework<\/strong><\/div>\n

      REST API \u6b63\u5728\u8fc5\u901f\u6210\u4e3a\u73b0\u4ee3 Web \u5e94\u7528\u7684\u6807\u51c6\u529f\u80fd\u3002 API \u5c31\u662f\u7b80\u5355\u7684\u4f7f\u7528 JSON \u5bf9\u8bdd\u800c\u4e0d\u662f HTML\uff0c\u5f53\u7136\u4f60\u53ef\u4ee5\u53ea\u7528 Django \u505a\u5230\u8fd9\u4e9b\u3002\u4f60\u53ef\u4ee5\u5236\u4f5c\u81ea\u5df1\u7684\u89c6\u56fe\uff0c\u8bbe\u7f6e\u5408\u9002\u7684 Content-Type\uff0c\u7136\u540e\u8fd4\u56de JSON \u800c\u4e0d\u662f\u6e32\u67d3\u540e\u7684 HTML \u54cd\u5e94\u3002\u8fd9\u662f\u5728\u50cf Django Rest Framework\uff08\u4e0b\u79f0 DRF\uff09\u8fd9\u6837\u7684 API \u6846\u67b6\u53d1\u5e03\u4e4b\u524d\uff0c\u5927\u591a\u6570\u4eba\u6240\u505a\u7684\u3002<\/p>\n

      \u5982\u679c\u4f60\u5bf9 Django \u7684\u89c6\u56fe\u7c7b\u5f88\u719f\u6089\uff0c\u4f60\u4f1a\u89c9\u5f97\u4f7f\u7528 DRF \u6784\u5efa REST API \u4e0e\u4f7f\u7528\u5b83\u4eec\u5f88\u76f8\u4f3c\uff0c\u4e0d\u8fc7 DRF \u53ea\u9488\u5bf9\u7279\u5b9a API \u4f7f\u7528\u573a\u666f\u800c\u8bbe\u8ba1\u3002\u4e00\u822c\u7684 API \u8bbe\u7f6e\u53ea\u9700\u8981\u4e00\u70b9\u4ee3\u7801\uff0c\u6240\u4ee5\u6211\u4eec\u6ca1\u6709\u63d0\u4f9b\u4e00\u4efd\u8ba9\u4f60\u5174\u594b\u7684\u793a\u4f8b\u4ee3\u7801\uff0c\u800c\u662f\u5f3a\u8c03\u4e86\u4e00\u4e9b\u53ef\u4ee5\u8ba9\u4f60\u751f\u6d3b\u7684\u66f4\u8212\u9002\u7684 DRF \u7279\u6027\uff1a<\/p>\n

        \n
      1. \u53ef\u81ea\u52a8\u9884\u89c8\u7684 API \u53ef\u4ee5\u4f7f\u4f60\u7684\u5f00\u53d1\u548c\u4eba\u5de5\u6d4b\u8bd5\u8f7b\u800c\u6613\u4e3e\u3002\u4f60\u53ef\u4ee5\u67e5\u770b DRF \u7684\u793a\u4f8b\u4ee3\u7801\u3002\u4f60\u53ef\u4ee5\u67e5\u770b API \u54cd\u5e94\uff0c\u5e76\u4e14\u4e0d\u9700\u8981\u4f60\u505a\u4efb\u4f55\u4e8b\u5c31\u53ef\u4ee5\u652f\u6301 POST\/PUT\/DELETE \u7c7b\u578b\u7684\u64cd\u4f5c\u3002<\/li>\n
      2. \u4fbf\u4e8e\u96c6\u6210\u5404\u79cd\u8ba4\u8bc1\u65b9\u5f0f\uff0c\u5982 OAuth, Basic Auth, \u6216API Tokens\u3002<\/li>\n
      3. \u5185\u5efa\u8bf7\u6c42\u901f\u7387\u9650\u5236\u3002<\/li>\n
      4. \u5f53\u4e0e django-rest-swagger \u7ec4\u5408\u4f7f\u7528\u65f6\uff0cAPI \u6587\u6863\u51e0\u4e4e\u53ef\u4ee5\u81ea\u52a8\u751f\u6210\u3002<\/li>\n
      5. \u5e7f\u6cdb\u7684\u7b2c\u4e09\u65b9\u5e93\u751f\u6001\u3002<\/li>\n<\/ol>\n

        \u5f53\u7136\uff0c\u4f60\u53ef\u4ee5\u4e0d\u4f9d\u8d56 DRF \u6765\u6784\u5efa API\uff0c\u4f46\u6211\u4eec\u65e0\u6cd5\u60f3\u8c61\u4f60\u4e0d\u53bb\u4f7f\u7528 DRF \u7684\u539f\u56e0\u3002\u5c31\u7b97\u4f60\u4e0d\u4f7f\u7528 DRF \u7684\u5168\u90e8\u7279\u6027\uff0c\u4f7f\u7528\u4e00\u4e2a\u6210\u719f\u7684\u89c6\u56fe\u5e93\u6765\u6784\u5efa\u4f60\u81ea\u5df1\u7684 API \u4e5f\u4f1a\u4f7f\u4f60\u7684 API \u66f4\u52a0\u4e00\u81f4\u3001\u5b8c\u5168\uff0c\u66f4\u80fd\u63d0\u9ad8\u4f60\u7684\u5f00\u53d1\u901f\u5ea6\u3002\u5982\u679c\u4f60\u8fd8\u6ca1\u6709\u5f00\u59cb\u4f7f\u7528 DRF, \u4f60\u5e94\u8be5\u627e\u70b9\u65f6\u95f4\u53bb\u4f53\u9a8c\u4e00\u4e0b\u3002<\/p>\n

        \u57fa\u4e8e Django \u7684\u6700\u4f73 CMS\uff1aWagtail<\/strong><\/div>\n

        Wagtail \u662f\u5f53\u4e0b Django CMS\uff08\u5185\u5bb9\u7ba1\u7406\u7cfb\u7edf\uff09\u4e16\u754c\u4e2d\u6700\u53d7\u4eba\u9752\u7750\u7684\u5e94\u7528\uff0c\u5e76\u4e14\u5b83\u7684\u70ed\u95e8\u6709\u8db3\u591f\u7684\u7406\u7531\u3002\u5c31\u50cf\u5927\u591a\u6570\u7684 CMS \u4e00\u6837\uff0c\u5b83\u5177\u6709\u6781\u4f73\u7684\u7075\u6d3b\u6027\uff0c\u53ef\u4ee5\u901a\u8fc7\u7b80\u5355\u7684 Django \u6a21\u578b\u6765\u5b9a\u4e49\u4e0d\u540c\u7c7b\u578b\u7684\u9875\u9762\u53ca\u5176\u5185\u5bb9\u3002\u4f7f\u7528\u5b83\uff0c\u4f60\u53ef\u4ee5\u4ece\u96f6\u5f00\u59cb\u5728\u51e0\u4e2a\u5c0f\u65f6\u800c\u4e0d\u662f\u51e0\u5929\u4e4b\u5185\u6765\u548c\u5efa\u9020\u4e00\u4e2a\u57fa\u672c\u53ef\u4ee5\u8fd0\u884c\u7684\u5185\u5bb9\u7ba1\u7406\u7cfb\u7edf\u3002\u4e3e\u4e00\u4e2a\u5c0f\u4f8b\u5b50\uff0c\u4e3a\u4f60\u516c\u53f8\u7684\u5458\u5de5\u5b9a\u4e49\u4e00\u4e2a\u5458\u5de5\u9875\u9762\u7c7b\u578b\u53ef\u4ee5\u50cf\u4e0b\u9762\u4e00\u6837\u7b80\u5355\uff1a<\/p>\n

        from wagtail.wagtailcore.models import Page\r\nfrom wagtail.wagtailcore.fields import RichTextField\r\nfrom wagtail.wagtailadmin.edit_handlers import FieldPanel, MultiFieldPanel\r\nfrom wagtail.wagtailimages.edit_handlers import ImageChooserPanel \r\n\r\nclass StaffPage(Page):\r\n    name = models.CharField(max_length=100)\r\n    hire_date = models.DateField()\r\n    bio = models.RichTextField()\r\n    email = models.EmailField()\r\n    headshot = models.ForeignKey('wagtailimages.Image', null=True, blank=True) \r\n    content_panels = Page.content_panels + [\r\n                                FieldPanel('name'),\r\n                                FieldPanel('hire_date'),\r\n                                FieldPanel('email'),\r\n                                FieldPanel('bio',classname=\"full\"),\r\n                                ImageChoosePanel('headshot'),\r\n                                ] \r\n<\/pre>\n

        \u7136\u800c\uff0cWagtail \u771f\u6b63\u51fa\u5f69\u7684\u5730\u65b9\u5728\u4e8e\u5b83\u7684\u7075\u6d3b\u6027\u53ca\u5176\u6613\u4e8e\u4f7f\u7528\u7684\u73b0\u4ee3\u5316\u7ba1\u7406\u9875\u9762\u3002\u4f60\u53ef\u4ee5\u63a7\u5236\u4e0d\u540c\u7c7b\u578b\u7684\u9875\u9762\u5728\u54ea\u7f51\u7ad9\u7684\u54ea\u4e9b\u533a\u57df\u53ef\u4ee5\u8bbf\u95ee\uff0c\u4e3a\u9875\u9762\u6dfb\u52a0\u590d\u6742\u7684\u9644\u52a0\u903b\u8f91\uff0c\u8fd8\u5929\u751f\u5c31\u652f\u6301\u6807\u51c6\u7684\u9002\u5e94\/\u5ba1\u6279\u5de5\u4f5c\u6d41\u3002\u5728\u5927\u591a\u6570 CMS \u7cfb\u7edf\u4e2d\uff0c\u4f60\u4f1a\u5728\u5f00\u53d1\u65f6\u5728\u67d0\u4e9b\u70b9\u4e0a\u9047\u5230\u56f0\u96be\u3002\u800c\u4f7f\u7528 Wagtail \u65f6\uff0c\u6211\u4eec\u7ecf\u8fc7\u4e0d\u61c8\u52aa\u529b\u627e\u5230\u4e86\u4e00\u4e2a\u7a81\u7834\u53e3\uff0c\u4f7f\u5f97\u8ba9\u6211\u4eec\u8f7b\u6613\u5730\u5f00\u53d1\u51fa\u4e00\u5957\u7b80\u6d01\u7a33\u5b9a\u7684\u7cfb\u7edf\uff0c\u4f7f\u5f97\u7a0b\u5e8f\u5b8c\u5168\u4f9d\u7167\u6211\u4eec\u7684\u60f3\u6cd5\u8fd0\u884c\u3002\u5982\u679c\u4f60\u5bf9\u6b64\u611f\u5174\u8da3\uff0c\u6211\u4eec\u5199\u4e86\u4e00\u7bc7[\u6df1\u5165\u7406\u89e3 Wagtail][17\u3002<\/p>\n

        \u63d0\u4f9b\u793e\u4ea4\u8d26\u6237\u767b\u5f55\u7684\u6700\u4f73\u5de5\u5177\uff1adjango-allauth<\/strong><\/div>\n

        django-allauth \u662f\u4e00\u4e2a\u80fd\u591f\u89e3\u51b3\u4f60\u7684\u6ce8\u518c\u548c\u8ba4\u8bc1\u9700\u6c42\u7684\u3001\u53ef\u91cd\u7528\u7684 Django \u5e94\u7528\u3002\u65e0\u8bba\u4f60\u9700\u8981\u6784\u5efa\u672c\u5730\u6ce8\u518c\u7cfb\u7edf\u8fd8\u662f\u793e\u4ea4\u8d26\u6237\u6ce8\u518c\u7cfb\u7edf\uff0cdjango-allauth \u90fd\u80fd\u591f\u5e2e\u4f60\u505a\u5230\u3002<\/p>\n

        \u8fd9\u4e2a\u5e94\u7528\u652f\u6301\u591a\u79cd\u8ba4\u8bc1\u4f53\u7cfb\uff0c\u6bd4\u5982\u7528\u6237\u540d\u6216\u7535\u5b50\u90ae\u4ef6\u3002\u4e00\u65e6\u7528\u6237\u6ce8\u518c\u6210\u529f\uff0c\u5b83\u8fd8\u53ef\u4ee5\u63d0\u4f9b\u4ece\u65e0\u9700\u8ba4\u8bc1\u5230\u7535\u5b50\u90ae\u4ef6\u8ba4\u8bc1\u7684\u591a\u79cd\u8d26\u6237\u9a8c\u8bc1\u7684\u7b56\u7565\u3002\u540c\u65f6\uff0c\u5b83\u4e5f\u652f\u6301\u591a\u79cd\u793e\u4ea4\u8d26\u6237\u548c\u7535\u5b50\u90ae\u4ef6\u8d26\u6237\u3002\u5b83\u8fd8\u652f\u6301\u63d2\u62d4\u5f0f\u6ce8\u518c\u8868\u5355\uff0c\u53ef\u8ba9\u7528\u6237\u5728\u6ce8\u518c\u65f6\u56de\u7b54\u4e00\u4e9b\u9644\u52a0\u95ee\u9898\u3002<\/p>\n

        django-allauth \u652f\u6301\u591a\u4e8e 20 \u79cd\u8ba4\u8bc1\u63d0\u4f9b\u8005\uff0c\u5305\u62ec Facebook\u3001Github\u3001Google \u548c Twitter\u3002\u5982\u679c\u4f60\u53d1\u73b0\u4e86\u4e00\u4e2a\u5b83\u4e0d\u652f\u6301\u7684\u793e\u4ea4\u7f51\u7ad9\uff0c\u5f88\u6709\u53ef\u80fd\u901a\u8fc7\u7b2c\u4e09\u65b9\u63d2\u4ef6\u63d0\u4f9b\u8be5\u7f51\u7ad9\u7684\u63a5\u5165\u652f\u6301\u3002\u8fd9\u4e2a\u9879\u76ee\u8fd8\u652f\u6301\u81ea\u5b9a\u4e49\u540e\u7aef\uff0c\u53ef\u4ee5\u652f\u6301\u81ea\u5b9a\u4e49\u7684\u8ba4\u8bc1\u65b9\u5f0f\uff0c\u5bf9\u6bcf\u4e2a\u6709\u5b9a\u5236\u8ba4\u8bc1\u9700\u6c42\u7684\u4eba\u6765\u8bf4\u8fd9\u90fd\u5f88\u68d2\u3002<\/p>\n

        django-allauth \u6613\u4e8e\u914d\u7f6e\uff0c\u4e14\u6709\u5b8c\u5584\u7684\u6587\u6863\u3002\u8be5\u9879\u76ee\u901a\u8fc7\u4e86\u5f88\u591a\u6d4b\u8bd5\uff0c\u6240\u4ee5\u4f60\u53ef\u4ee5\u76f8\u4fe1\u5b83\u7684\u6240\u6709\u90e8\u4ef6\u90fd\u4f1a\u6b63\u5e38\u8fd0\u4f5c\u3002<\/p>\n

        \n

        \u539f\u6587\u6765\u81ea\uff1ahttp:\/\/blog.chinaunix.net\/uid-7573623-id-2048961.html<\/a><\/p>\n

        \u672c\u6587\u5730\u5740\uff1ahttp:\/\/lrxjmw.cn\/source-django-package.html<\/a>\u7f16\u8f91\uff1a\u6768\u5e06\uff0c\u5ba1\u6838\u5458\uff1a\u51af\u742a<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

        Django \u56f4\u7ed5“\u53ef\u91cd\u7528\u5e94\u7528”\u7684\u601d\u60f3\u5efa\u7acb\uff1a\u81ea\u5305\u542b\u7684\u5305\u63d0\u4f9b\u4e86\u53ef\u91cd\u590d\u4f7f\u7528\u7684\u7279\u6027\u3002\u4f60\u53ef\u4ee5\u5c06\u8fd9\u4e9b\u53ef\u91cd\u7528\u5e94\u7528\u7ec4\u88c5\u8d77\u6765\uff0c\u5728\u52a0\u4e0a\u9002\u7528\u4e8e\u4f60\u7684\u7f51\u7ad9\u7684\u7279\u5b9a\u4ee3\u7801\uff0c\u6765\u642d\u5efa\u4f60\u81ea\u5df1\u7684\u7f51\u7ad9\u3002Django \u5177\u6709\u4e00\u4e2a\u4e30\u5bcc\u591a\u6837\u7684\u3001\u7531\u53ef\u4f9b\u4f60\u4f7f\u7528\u7684\u53ef\u91cd\u7528\u5e94\u7528\u7ec4\u5efa\u8d77\u6765\u7684\u751f\u6001\u7cfb\u7edf——PyPI \u5217\u51fa\u4e86\u8d85\u8fc7 8000\u4e2a Django \u5e94\u7528——\u53ef\u4f60\u8be5\u5982\u4f55\u77e5\u9053\u54ea\u4e9b\u662f\u6700\u597d\u7684\u5462\uff1f<\/p>\n","protected":false},"author":63,"featured_media":27016,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-26579","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/26579","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=26579"}],"version-history":[{"count":13,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/26579\/revisions"}],"predecessor-version":[{"id":257799,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/26579\/revisions\/257799"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/27016"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=26579"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=26579"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=26579"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}