- Django Project Blueprints
- Asad Jibran Ahmed
- 132字
- 2021-07-16 10:37:45
Chapter 2. Discuss – a Hacker News Clone
In this chapter, we'll be creating a web app similar to Hacker News or Reddit, where users can share and discuss links to web content. We'll call the application Discuss. To keep things simple, we'll be emulating the minimalistic look of Hacker News, which is text only and has a very simple interface. Reddit, on the other hand, is much more visually rich and has a lot of extra features that we won't be adding to our site.
Here's an outline of what we'll be covering in this chapter:
- Allowing users to submit their own content
- Allowing users to vote on content submitted by other users
- Ranking the user-submitted content based on simple algorithms
- Preventing spammers from abusing our site using captchas
Chapter code packs
If you have developed a few Django applications, you'll probably know that for most applications, a lot of the code and configurations that you do when starting out is the same. You set up the database in the same way, maybe changing the Database (DB) name and user/pass pairs, you set up your media, static URL, and root paths, and then you add user authentication using the built-in auth contrib
application and the provided views, only creating minimal templates that are good enough to get the job done in the start.
Walking you through the basic setup at the start of every chapter would be very boring—both for you to read and for me to write. Instead, I've provided what I call Code Packs. These are zip
files that contain the Django application already set up so that we can jump straight to the interesting parts of the code instead of having to go through the tedious setup process again and again.
Don't worry, I won't skip any new Django features that we haven't looked at yet. Each code pack contains code that has already been explained to you in previous chapters. For instance, the code pack for this chapter contains a Django application that has the user registration, login, and logout views, templates, and URLs already set up. This is the stuff that we have already looked at in detail in the previous chapter.
To use these code packs, you will need to download them, unzip them in the project root folder, and create a virtual environment for them. Then, you'll need to run the following command to have Django installed in your new virtual environment:
> pip install django > python manage.py migrate
Once you've done all these steps, you'll be ready to start working on the fun parts of the application. For all the following chapters, I've given you the link to the code pack and I assume that you have already extracted and set up a virtual environment for it.
- Getting Started with oVirt 3.3
- Red Hat Enterprise Linux 8系統管理實戰
- 計算機系統:基于x86+Linux平臺
- 云原生落地:產品、架構與商業模式
- Linux服務器配置與管理
- Python UNIX和Linux系統管理指南
- CentOS 6 Linux Server Cookbook
- Linux 從入門到項目實踐(超值版)
- 基于Arduino的嵌入式系統入門與實踐
- 15分鐘!畫出我的漫畫角色:賣萌篇
- OpenSolaris紅寶書
- C#實用教程(第2版)
- 計算機操作系統(第3版)(微課版)
- 分布式實時處理系統:原理、架構與實現
- Building E-commerce Sites with Drupal Commerce Cookbook