- 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.
- Google系統架構解密:構建安全可靠的系統
- 構建可擴展分布式系統:方法與實踐
- Linux使用和管理指南:從云原生到可觀測性
- 8051軟核處理器設計實戰
- 注冊表應用完全DIY
- RHCSARHCE 紅帽Linux認證學習指南(第7版)EX200 & EX300
- Distributed Computing with Go
- Python UNIX和Linux系統管理指南
- Windows Vista終極技巧金典
- Drupal 7 Cookbook
- 嵌入式微系統
- 大學計算機應用基礎實踐教程(Windows 7+MS Office 2010)
- 應急指揮信息系統設計
- Learn OpenShift
- openEuler操作系統核心技術與行業應用實踐