Final code for the project blog of Chapters 18-20 from the book: PYTHON CRASH COURSE 3rd EDITION: A Hands-On, Project-Based Introduction to Programming by Eric Matthes.
Link to the book's solutions repo
Note:
- This code is only for local use and has no configurations for a cloud deployment.
- This has few additional features(refer below) which are not mentioned in the book.
Additional Features
- Added
visibility
attribute to the Topic model for public & private topics (similar to the blog project) - Removed help text in the Registration page.
- Restriction of register, login & logout pages as per the user's authentication.
- This is to prevent a scenario like: Logged-in user trying the access the register or login url.
- This is implemented using custom middleware in the
accounts
app.
- New
edit-topic
feature to edit a blog's title & visibility. - Conditional Display of
create-entry
,edit-entry
&edit-topic
links in topic page based on the user's authentication. - Recent Entries section in the Home page.
How to run this project:
- Create a new virtual environment with the packages mentioned in requirements.txt and activate it.
- Run
python manage.py migrate
to create a newdb.sqlite3
. - Run
python manage.py createsuperuser
to create a new admin user.- Enter username, email & password(won't be displayed)
- Run
python manage.py runserver
to run the project. - Visit the url shown in the terminal
- For Ex.
https://127.0.0.1:8000/
- For Ex.
- To access the admin dashboard, visit the
/admin
subpage.- For Ex.
https://127.0.0.1:8000/admin
- For Ex.
Learning Outcomes:
- Basic MVT architecture of Django
- Function based Views
- Forms in Django
- Basic Auth Functionality using Django
- Template Inheritance in Django
- Applying Bootstrap5 styling in Django
- Custom Middlewares in Django
- Languages used : python3,html
- Frameworks used : django
- Libraries used : django-bootstrap5
- Tech Domain : Full-Stack-Development