- Django Project Blueprints
- Asad Jibran Ahmed
- 373字
- 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.
- Implementing Cisco UCS Solutions
- Linux實戰(zhàn)
- Linux網(wǎng)絡操作系統(tǒng)與實訓(第三版)
- Kubernetes網(wǎng)絡權威指南:基礎、原理與實踐
- Linux Shell編程從入門到精通(第2版)
- Linux系統(tǒng)安全基礎:二進制代碼安全性分析基礎與實踐
- AWS Development Essentials
- Windows 8實戰(zhàn)從入門到精通(超值版)
- Windows 10從新手到高手
- Web Penetration Testing with Kali Linux(Third Edition)
- 大學計算機應用基礎實踐教程(Windows 7+MS Office 2010)
- Linux內(nèi)核分析及應用
- openEuler操作系統(tǒng)核心技術與行業(yè)應用實踐
- Mastering Eclipse Plug-in Development
- 物聯(lián)網(wǎng)操作系統(tǒng)AliOS Things探索與實踐