Django開發(fā)社交類網(wǎng)站必備的10個第三方應(yīng)用
時間:2023-03-13 21:22:01 | 來源:電子商務(wù)
時間:2023-03-13 21:22:01 來源:電子商務(wù)
Django 的好處就是大而全,不僅內(nèi)置了 ORM、表單、模板引擎、用戶系統(tǒng)等,而且第三方應(yīng)用的生態(tài)也是十分完善,開發(fā)中大部分常見的功能都能找到對應(yīng)的第三方實現(xiàn)。在這里給大家推薦 10 個十分優(yōu)秀的 Django 第三方庫(GitHub 星星數(shù)基本都在 1000 以上,而且都在持續(xù)維護與更新中)。雖然這些庫很適合用于社交網(wǎng)站的開發(fā),但也有很大一部分是通用的,可以用于任何用 Django 開發(fā)的項目。使用這些庫將大大提高開發(fā)效率和生產(chǎn)力。
django-model-utils
簡介:Django model mixins and utilities.
GitHub 地址:https://github.com/jazzband/django-model-utils
文檔地址:http://django-model-utils.readthedocs.io/en/latest/
點評:增強 Django 的 model 模塊。內(nèi)置了一些通用的 model Mixin,例如
TimeStampedModel
為模型提供一個創(chuàng)建時間和修改時間的字段,還有一些有用的 Field,幾乎每個 Django 項目都能用得上。
django-allauth
簡介:Integrated set of Django applications addressing authentication, registration, account management as well as 3rd party (social) account authentication.
GitHub 地址:https://github.com/pennersr/django-allauth
文檔地址:https://django-allauth.readthedocs.io/en/latest/
點評:增強 Django 內(nèi)置的 django.contrib.auth 模塊,提供登錄、注冊、郵件驗證、找回密碼等一切用戶驗證相關(guān)的功能。另外還提供 OAuth 第三方登錄功能,例如國內(nèi)的微博、微信登錄,國外的 GitHub、Google、facebook 登錄等,幾乎囊括了大部分熱門的第三方賬戶登錄。配置簡單,開箱即用。
django-crispy-forms
簡介:The best way to have DRY Django forms. The app provides a tag and filter that lets you quickly render forms in a div format while providing an enormous amount of capability to configure and control the rendered HTML.
GitHub 地址:https://github.com/django-crispy-forms/django-crispy-forms
文檔地址:http://django-crispy-forms.rtfd.org/
點評:大大增強 Django 內(nèi)置的表單功能,Django 內(nèi)置的表單生成原生的 HTML 表單代碼還可以,但為其設(shè)置樣式是一個麻煩的事情。django-crispy-forms 幫助你使用一行代碼渲染一個 Bootstrap 樣式的表單,當(dāng)然它還支持其它一些熱門的 CSS 框架樣式的渲染。
django-mptt
簡介:Utilities for implementing a modified pre-order traversal tree in django.
GitHub 地址:https://github.com/django-mptt/django-mptt
文檔地址:https://django-mptt.readthedocs.io/
點評:配合 Django 的 ORM 系統(tǒng),為數(shù)據(jù)庫的記錄生成樹形結(jié)構(gòu),并提供便捷的操作樹型記錄的 API。例如可以使用它實現(xiàn)一個多級的評論系統(tǒng)??傊?,只要你的數(shù)據(jù)結(jié)構(gòu)可能需要使用樹來表示,django-mptt 將大大提高你的開發(fā)效率。
django-contrib-comments
簡介:Django used to include a comments framework; since Django 1.6 it's been separated to a separate project. This is that project.
This framework can be used to attach comments to any model, so you can use it for comments on blog entries, photos, book chapters, or anything else.
GitHub 地址:https://github.com/django/django-contrib-comments
文檔地址:https://django-contrib-comments.readthedocs.io/
點評:用于提供評論功能,最先集成在 django 的 contrib 內(nèi)置庫里,后來被移出來單獨維護(可能覺得評論并非是一個通用的庫吧)。這個評論庫提供了基本的評論功能,但是只支持單級評論。好在這個庫具有很好的拓展性,基于上邊提到的 django-mptt,就可以構(gòu)建一個支持層級評論的評論庫,就像 我的博客評論區(qū) 中展示的這樣(個人博客的評論模塊就是基于 django-contrib-comments 和 django-mptt 寫的)。
django-imagekit
簡介:Automated image processing for Django.
GitHub 地址:https://github.com/matthewwithanm/django-imagekit
文檔地址:http://django-imagekit.rtfd.org/
點評:社交類網(wǎng)站免不了處理一些圖片,例如頭像、用戶上傳的圖片等內(nèi)容。django-imagekit 幫你配合 django 的 model 模塊自動完成圖片的裁剪、壓縮、生成縮略圖等一系列圖片相關(guān)的操作。
django-brace
簡介:Reusable, generic mixins for Django
GitHub 地址:https://github.com/brack3t/django-braces
文檔地址:http://django-braces.readthedocs.io/en/latest/index.html
點評:django 內(nèi)置的 class based view 很 awesome,但還有一些通用的類視圖沒有包含在 django 源碼中,這個庫補充了更多常用的類視圖。類視圖是 django 的一個很重要也很優(yōu)雅的特性,使用類視圖可以減少視圖函數(shù)的代碼編寫量、提高視圖函數(shù)的代碼復(fù)用性等。深入學(xué)習(xí)類視圖可以看Django類視圖源碼分析。
django-notifications-hq
簡介:GitHub notifications alike app for Django
GitHub 地址:https://github.com/django-notifications/django-notifications
文檔地址:https://pypi.python.org/pypi/django-notifications-hq/
點評:沒什么好說的,為你的網(wǎng)站提供類似于 GitHub 這樣的通知功能。未讀通知數(shù)、通知列表、標(biāo)為已讀等等。
django-simple-captcha
簡介:Django Simple Captcha is an extremely simple, yet highly customizable Django application to add captcha images to any Django form.
GitHub 地址:https://github.com/mbi/django-simple-captcha
文檔地址:http://django-simple-captcha.readthedocs.io/en/latest/
點評:配合 django 的表單模塊,方便地為表單添加一個驗證碼字段。對驗證性要求不高的需求,例如注冊表單防止機器人自動注冊等使用起來非常方便。
django-anymail
簡介:Django email backends and webhooks for Mailgun, Mailjet, Postmark, SendGrid, SparkPost and more
GitHub 地址:https://github.com/anymail/django-anymail
文檔地址:https://anymail.readthedocs.io/
點評:配合 django 的 email 模塊,只需簡單配置,就可以使用 Mailgun、SendGrid 等發(fā)送郵件。
django-activity-stream
簡介:Generate generic activity streams from the actions on your site. Users can follow any actors' activities for personalized streams.
GitHub 地址:https://github.com/justquick/django-activity-stream
文檔地址:http://django-activity-stream.rtfd.io/en/latest/
點評:社交類網(wǎng)站免不了關(guān)注、收藏、點贊、用戶動態(tài)等功能,這一個 app 全搞定。甚至用它實現(xiàn)一個朋友圈也不是不可能。