Project 10 - Cards & Tables & Docs
Goals
- Extend Data Views with Fancy Views
- Build an applications that has for generic Django views for the CRUD operations
- Django View Design Patterns
- CardView
- TableView
- DocumentView
- Use View Tricks
- View Inheritance
- Partial Templates
- include "_navbar.html"
- include "_user.html"
- include "_header.html"
- include "_footer.html"
- include "_card.html"
- include "_cards.html"
- include "_doc.html"
- User Management
- Users can Register
- Users login/logout
- Edit operations require login
Steps
Build out the Superhero Django Project
Create Superhero Theme
- Create a base page template
- Style all pages without duplicating any code
- Create a HTML template "superhero_theme.html"
- Add a bootstrap CSS and custom CSS to this template
- Add a "{% block content %}" section to the template
- Make index.html and hero.html use "{% extends 'superhero_theme.html' %}"
- Debug the view inheritance
- Give you pages some cool style
Create Superhero Pages
- Build one set of templates
- Build view that take arguments and displays the contents
- Build a URL route that call your view
Create Images
- Create images that match your five selected heroes
- Add an image to your view to display the superhero image
- Debug your application code until photos display
- Commit to your Github repo
- Deploy at Python Anywhere
Superhero data records
- Superhero Record
- name
- identity
- description
- strength
- weakness
- image
- Add five Superhero data records
Use View Tricks
- View Inheritance
- Inherit from "superhero_theme.html"
- Blocks
- content
- header
- footer
- main
- navbar
- user
- Partial Templates
- _navbar.html
- _user.html
- _header.html
- _footer.html
- _card.html
- _cards.html
- _doc.html
Test the pages
- Browse to http://YOUR_USER.pythonanywhere.com for Your Site
- Make sure this address is set in Sensei
Requirements
- Your page must be available at http://YOUR_USER.pythonanywhere.com
- It must contain info about superheroes
- All heroes must come from database records
- ListView, DetailView
- CreateView, UpdateView,DeleteView requires login
- Partial templates and includes
- Register
- View Inheritance - "superhero_theme.html" base template for all pages
- Nice page style and layout