In Module 5, you will learn about Git, a version control system, and Django, a web framework.
This article contains your assignments for Module 5.
The following articles on the online class wiki textbook contain information that will help you complete the assignments.
Learn about Version Control Systems
On your own time, watch the 40-minute screencast that has been posted to Blackboard. This gives an insightful understanding of how VCSs work under-the-hood.
The web framework we will be using in Module 5 is called Django. Django is the dominant Python-based web framework and is useful for large web sites.
Before you may begin, you need to install Django. You may do this using pip, which you installed in Module 4. Django's package name in pip is Django.
Once you have Django installed, complete the official Django tutorial. You will be creating a simple poll app. There are four parts to the tutorial.
It is important that you do all the steps in the tutorial in order to get comfortable defining models, views, templates, and using the interactive shell and the admin app. Understanding these concepts will make the project go much quicker.
Tip: It is recommended that you install a copy of Python and Django on your local computer. This way, you will not need to upload the files to your server every time you make a change, because your server will be running locally.
- Part 1
- Create a project
- Start the development server
- Setup an SQLite database
- Create the Polls app and define the models
- Interact with the database using the interactive python shell
- Part 2
- Activate the admin site
- Add the poll app to the admin site
- Modify the database using the admin site
- Part 3
- Configure URL handling
- Create some views
- Part 4
- Write a form that modifies the database
- Refactor to use generic views
Extending the Polls App using Version Control
As your group project, you and your partner will each independently add an additional feature to the polls app you made in the individual portion. You will each be working in your own branch in your group Git repository. When the features are complete, you will merge them back into the master branch.
- Someone in your group needs to copy their tutorial code from the individual portion into the master branch of the group repository.
- After pushing and pulling, everyone should have the up-to-date master branch on their machine.
- Each person in the group should then make a new branch named with their first name.
- Each person can then individually work on their new feature. Here are some ideas for new features that will all earn full credit:
- Enable users to create and edit their own polls
- Add user accounts. Polls voted on would be associated with the account
- Check for double votes using Cookie and/or IP
- Set a timeout for polls (e.g., the poll is active for only 7 days)
- Add a banner ad to the site that changes on a page reload (you could use Google Adsense or similar)
- If there is a feature not on this list that you would like to add, please ask a TA.
- When someone completes their feature, they should merge their branch into the master branch, and everyone else in the group should merge the master branch (which now has the new feature) into their personal working branch.
On Demo Day, you will need to show the branching structure of your repository in SourceTree to the TA.
As your creative portion, add two more features to your polls app, at least one of which shouldn't be in the list above.
Web Security and Validation
Web frameworks take care of a lot of the security practices you learned in modules 2 and 3. For more information on Django security, refer to the Django documentation: https://docs.djangoproject.com/en/dev/topics/security/
You still need to ensure that all pages on your site pass the W3C validation.
We will be grading the following aspects of your work. There are 75 points total.
- Version Control Screencast (5 Points)
- Django Tutorial (15 points):
- Database schema and models set up (4 points)
- Admin page working (4 points)
- URL routing is correct (3 points)
- Correct implementation of MVC (or, shall we say, MTV) architecture (4 points)
- Extend Polls Application (45 Points):
- Version Control (15 Points):
- Each team member has their own branch in Git (5 points)
- The branching view in SourceTree indicates that features were merged into master as they were completed and from there merged into each member's working branch (10 points)
- Features (20 Points):
- The rubric for each feature is shown below; each one is worth 10 points. You need only two additional features; a third will count toward the Creative Portion.
- Poll Creation and Editing
- Users can specify any number of choices for the poll
- If the "Timeout" feature is implemented, a timeout can be specified for the poll
- Note: When a poll is edited, you can choose whether to always reset all votes, or whether to keep old votes between edits of the poll.
- User Accounts
- Users can log in and log out
- Votes on polls are associated with a user
- Preventing Double Votes
- If using the IP-based approach, you store the IP address using the correct SQL data type (i.e., not a string)
- If using the cookie-based approach, your cookie format is not something that the end user can easily figure out and manipulate
- Poll Timeout
- Polls can have specified start times and end times
- The poll entirely shuts down when it is "off" (i.e., the template should not load and the view should not allow more votes to be cast)
- Best Practices (5 Points):
- Code is well organized and conforms to Django conventions (3 points)
- All pages pass the W3C validator (2 points)
- Usability (5 Points):
- Site is intuitive to use and navigate (4 points)
- Site is visually appealing (1 point)
- Version Control (15 Points):
- Creative Portion (10 Points)