官术网_书友最值得收藏!

Chapter 1. Blueblog – a Blogging Platform

We are going to start with a simple blogging platform in Django. In recent years, Django has emerged as one of the clear leaders in web frameworks. When most people decide to start using a web framework, their searches lead them to either Ruby on Rails (RoR) or Django. Both are mature, stable, and extensively used. It appears that the decision to use one or the other depends mostly on which programming language you're familiar with. Rubyists go with RoR, Pythonistas go with Django. In terms of features, both can be used to achieve the same results, although they have different approaches to how things are done.

One of the most popular blogging platforms these days is Medium, widely used by a number of high profile bloggers. Its popularity stems from its elegant theme, and simple-to-use interface. I'll walk you through creating a similar application in Django, with a few surprise features that most blogging platforms don't have. This will give you a taste of things to come, and show you just how versatile Django can be.

Before starting any software development project, it's a good idea to have a rough roadmap of what we would like to achieve. Here's a list of features that our blogging platform will have:

  • User should be able to register an account and create their blogs
  • Users should be able to tweak the settings of their blogs
  • There should be simple interface for users to create and edit blog posts
  • Users should be able to share their blog posts on other blogs on the platform

I know this seems like a lot of work, but Django comes with a couple of contrib packages that speed up our work considerably.


The contrib packages

The contrib packages are a part of Django that contain some very useful applications that the Django developers decided should be shipped with Django. The included applications provide an impressive set of features, including some that we'll be using in this application:

  • Admin is a full featured CMS that can be used to manage the content of a Django site. The Admin application is an important reason for the popularity of Django. We'll use this to provide an interface for site administrators to moderate and manage the data in our application
  • Auth provides user registration and authentication without requiring us to do any work. We'll be using this module to allow users to sign up, sign in, and manage their profiles in our application

Note

There are a lot more goodies in the contrib module. I suggest you take a look at the complete list at https://docs.djangoproject.com/en/stable/ref/contrib/#contrib-packages.

I usually end up using at least three of the contrib packages in all my Django projects. They provide often-required features like user registration and management, and free you to work on the core parts of your project, providing a solid foundation to build upon.

主站蜘蛛池模板: 巴东县| 盘锦市| 凤城市| 肇庆市| 布尔津县| 乐安县| 宣威市| 丹阳市| 竹山县| 保靖县| 深泽县| 乐清市| 宝应县| 安吉县| 博野县| 特克斯县| 山西省| 浮山县| 湟源县| 怀集县| 吉林市| 延寿县| 平顶山市| 顺昌县| 滨州市| 蒙阴县| 建昌县| 通榆县| 米泉市| 桂阳县| 石楼县| 巴中市| 泗水县| 丹凤县| 左云县| 永新县| 陇西县| 宿迁市| 沾化县| 桂林市| 康保县|